summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Wright <jonathan.wright@arm.com>2020-06-12 18:20:50 +0100
committerJonathan Wright <jonathan.wright@arm.com>2020-06-19 22:01:12 +0100
commit681ce7fc64d28fee365af84741a13d556409289c (patch)
tree7a2a30552e75727a4116dff125d4d1f2e1d09bf6
parent70be78f0c2958dcb8b6910d1f8b3ee0f5f4c20ea (diff)
Move tbench logs from stdout to stderr
gtest output prints to stdout. Printing unit test logs to stderr allows the two to be easily separated using stream redirection. Bug: 993876 Change-Id: I52d9d04ce7d6d883e9de09595fbe5a6de262c2ca
-rw-r--r--README.chromium1
-rw-r--r--tjbench.c267
2 files changed, 142 insertions, 126 deletions
diff --git a/README.chromium b/README.chromium
index 2e2a417..7d44f3a 100644
--- a/README.chromium
+++ b/README.chromium
@@ -76,6 +76,7 @@ following changes which are not merged to upstream:
- Move tjunittest logs from stdout to stderr
- Refactor tjbench.c to provide test interface
- Add gtest wrapper for tjbench tests
+ - Move tbench logs from stdout to stderr
Refer to working-with-nested-repos [1] for details of how to setup your git
svn client to update the code (for making local changes, cherry picking from
diff --git a/tjbench.c b/tjbench.c
index 94a0c5e..f555fae 100644
--- a/tjbench.c
+++ b/tjbench.c
@@ -38,7 +38,7 @@
#define _throw(op, err) { \
- printf("ERROR in line %d while %s:\n%s\n", __LINE__, op, err); \
+ fprintf(stderr, "ERROR in line %d while %s:\n%s\n", __LINE__, op, err); \
retval = -1; goto bailout; \
}
#define _throwunix(m) _throw(m, strerror(errno))
@@ -48,8 +48,8 @@ static char tjErrorStr[JMSG_LENGTH_MAX] = "\0",
static int tjErrorLine = -1, tjErrorCode = -1;
#define _throwtjg(m) { \
- printf("ERROR in line %d while %s:\n%s\n", __LINE__, m, \
- tjGetErrorStr2(NULL)); \
+ fprintf(stderr, "ERROR in line %d while %s:\n%s\n", __LINE__, m, \
+ tjGetErrorStr2(NULL)); \
retval = -1; goto bailout; \
}
@@ -65,12 +65,13 @@ static int tjErrorLine = -1, tjErrorCode = -1;
strncpy(tjErrorMsg, m, JMSG_LENGTH_MAX - 1); \
tjErrorCode = _tjErrorCode; \
tjErrorLine = __LINE__; \
- printf("WARNING in line %d while %s:\n%s\n", __LINE__, m, _tjErrorStr); \
+ fprintf(stderr, "WARNING in line %d while %s:\n%s\n", __LINE__, m, \
+ _tjErrorStr); \
} \
} else { \
- printf("%s in line %d while %s:\n%s\n", \
- _tjErrorCode == TJERR_WARNING ? "WARNING" : "ERROR", __LINE__, m, \
- _tjErrorStr); \
+ fprintf(stderr, "%s in line %d while %s:\n%s\n", \
+ _tjErrorCode == TJERR_WARNING ? "WARNING" : "ERROR", __LINE__, m, \
+ _tjErrorStr); \
retval = -1; goto bailout; \
} \
}
@@ -227,24 +228,26 @@ static int decomp(unsigned char *srcBuf, unsigned char **jpegBuf,
handle = NULL;
if (quiet) {
- printf("%-6s%s",
- sigfig((double)(w * h) / 1000000. * (double)iter / elapsed, 4,
- tempStr, 1024),
- quiet == 2 ? "\n" : " ");
+ fprintf(stderr, "%-6s%s",
+ sigfig((double)(w * h) / 1000000. * (double)iter / elapsed, 4,
+ tempStr, 1024),
+ quiet == 2 ? "\n" : " ");
if (doYUV)
- printf("%s\n",
- sigfig((double)(w * h) / 1000000. * (double)iter / elapsedDecode,
- 4, tempStr, 1024));
- else if (quiet != 2) printf("\n");
+ fprintf(stderr, "%s\n",
+ sigfig((double)(w * h) / 1000000. * (double)iter / elapsedDecode,
+ 4, tempStr, 1024));
+ else if (quiet != 2) fprintf(stderr, "\n");
} else {
- printf("%s --> Frame rate: %f fps\n",
- doYUV ? "Decomp to YUV" : "Decompress ", (double)iter / elapsed);
- printf(" Throughput: %f Megapixels/sec\n",
- (double)(w * h) / 1000000. * (double)iter / elapsed);
+ fprintf(stderr, "%s --> Frame rate: %f fps\n",
+ doYUV ? "Decomp to YUV" : "Decompress ", (double)iter / elapsed);
+ fprintf(stderr,
+ " Throughput: %f Megapixels/sec\n",
+ (double)(w * h) / 1000000. * (double)iter / elapsed);
if (doYUV) {
- printf("YUV Decode --> Frame rate: %f fps\n",
- (double)iter / elapsedDecode);
- printf(" Throughput: %f Megapixels/sec\n",
+ fprintf(stderr, "YUV Decode --> Frame rate: %f fps\n",
+ (double)iter / elapsedDecode);
+ fprintf(stderr,
+ " Throughput: %f Megapixels/sec\n",
(double)(w * h) / 1000000. * (double)iter / elapsedDecode);
}
}
@@ -267,7 +270,7 @@ static int decomp(unsigned char *srcBuf, unsigned char **jpegBuf,
ptr = strrchr(tempStr, '.');
snprintf(ptr, 1024 - (ptr - tempStr), "-err.%s", ext);
if (srcBuf && sf.num == 1 && sf.denom == 1) {
- if (!quiet) printf("Compression error written to %s.\n", tempStr);
+ if (!quiet) fprintf(stderr, "Compression error written to %s.\n", tempStr);
if (subsamp == TJ_GRAYSCALE) {
int index, index2;
@@ -326,9 +329,9 @@ static int fullTest(unsigned char *srcBuf, int w, int h, int subsamp,
_throwunix("allocating temporary image buffer");
if (!quiet)
- printf(">>>>> %s (%s) <--> JPEG %s Q%d <<<<<\n", pfStr,
- (flags & TJFLAG_BOTTOMUP) ? "Bottom-up" : "Top-down",
- subNameLong[subsamp], jpegQual);
+ fprintf(stderr, ">>>>> %s (%s) <--> JPEG %s Q%d <<<<<\n", pfStr,
+ (flags & TJFLAG_BOTTOMUP) ? "Bottom-up" : "Top-down",
+ subNameLong[subsamp], jpegQual);
for (tilew = doTile ? 8 : w, tileh = doTile ? 8 : h; ;
tilew *= 2, tileh *= 2) {
@@ -355,9 +358,9 @@ static int fullTest(unsigned char *srcBuf, int w, int h, int subsamp,
/* Compression test */
if (quiet == 1)
- printf("%-4s (%s) %-5s %-3d ", pfStr,
- (flags & TJFLAG_BOTTOMUP) ? "BU" : "TD", subNameLong[subsamp],
- jpegQual);
+ fprintf(stderr, "%-4s (%s) %-5s %-3d ", pfStr,
+ (flags & TJFLAG_BOTTOMUP) ? "BU" : "TD", subNameLong[subsamp],
+ jpegQual);
for (i = 0; i < h; i++)
memcpy(&tmpBuf[pitch * i], &srcBuf[w * ps * i], w * ps);
if ((handle = tjInitCompress()) == NULL)
@@ -419,45 +422,52 @@ static int fullTest(unsigned char *srcBuf, int w, int h, int subsamp,
if (tjDestroy(handle) == -1) _throwtj("executing tjDestroy()");
handle = NULL;
- if (quiet == 1) printf("%-5d %-5d ", tilew, tileh);
+ if (quiet == 1) fprintf(stderr, "%-5d %-5d ", tilew, tileh);
if (quiet) {
if (doYUV)
- printf("%-6s%s",
- sigfig((double)(w * h) / 1000000. *
- (double)iter / elapsedEncode, 4, tempStr, 1024),
- quiet == 2 ? "\n" : " ");
- printf("%-6s%s",
+ fprintf(stderr, "%-6s%s",
+ sigfig((double)(w * h) / 1000000. *
+ (double)iter / elapsedEncode, 4, tempStr, 1024),
+ quiet == 2 ? "\n" : " ");
+ fprintf(stderr, "%-6s%s",
sigfig((double)(w * h) / 1000000. * (double)iter / elapsed, 4,
tempStr, 1024),
quiet == 2 ? "\n" : " ");
- printf("%-6s%s",
- sigfig((double)(w * h * ps) / (double)totalJpegSize, 4, tempStr2,
- 80),
- quiet == 2 ? "\n" : " ");
+ fprintf(stderr, "%-6s%s",
+ sigfig((double)(w * h * ps) / (double)totalJpegSize, 4, tempStr2,
+ 80),
+ quiet == 2 ? "\n" : " ");
} else {
- printf("\n%s size: %d x %d\n", doTile ? "Tile" : "Image", tilew, tileh);
+ fprintf(stderr, "\n%s size: %d x %d\n", doTile ? "Tile" : "Image", tilew,
+ tileh);
if (doYUV) {
- printf("Encode YUV --> Frame rate: %f fps\n",
- (double)iter / elapsedEncode);
- printf(" Output image size: %d bytes\n", yuvSize);
- printf(" Compression ratio: %f:1\n",
- (double)(w * h * ps) / (double)yuvSize);
- printf(" Throughput: %f Megapixels/sec\n",
- (double)(w * h) / 1000000. * (double)iter / elapsedEncode);
- printf(" Output bit stream: %f Megabits/sec\n",
- (double)yuvSize * 8. / 1000000. * (double)iter / elapsedEncode);
+ fprintf(stderr, "Encode YUV --> Frame rate: %f fps\n",
+ (double)iter / elapsedEncode);
+ fprintf(stderr, " Output image size: %d bytes\n",
+ yuvSize);
+ fprintf(stderr, " Compression ratio: %f:1\n",
+ (double)(w * h * ps) / (double)yuvSize);
+ fprintf(stderr,
+ " Throughput: %f Megapixels/sec\n",
+ (double)(w * h) / 1000000. * (double)iter / elapsedEncode);
+ fprintf(stderr,
+ " Output bit stream: %f Megabits/sec\n",
+ (double)yuvSize * 8. / 1000000. * (double)iter / elapsedEncode
+ );
}
- printf("%s --> Frame rate: %f fps\n",
- doYUV ? "Comp from YUV" : "Compress ",
- (double)iter / elapsed);
- printf(" Output image size: %d bytes\n",
- totalJpegSize);
- printf(" Compression ratio: %f:1\n",
- (double)(w * h * ps) / (double)totalJpegSize);
- printf(" Throughput: %f Megapixels/sec\n",
- (double)(w * h) / 1000000. * (double)iter / elapsed);
- printf(" Output bit stream: %f Megabits/sec\n",
- (double)totalJpegSize * 8. / 1000000. * (double)iter / elapsed);
+ fprintf(stderr, "%s --> Frame rate: %f fps\n",
+ doYUV ? "Comp from YUV" : "Compress ",
+ (double)iter / elapsed);
+ fprintf(stderr, " Output image size: %d bytes\n",
+ totalJpegSize);
+ fprintf(stderr, " Compression ratio: %f:1\n",
+ (double)(w * h * ps) / (double)totalJpegSize);
+ fprintf(stderr,
+ " Throughput: %f Megapixels/sec\n",
+ (double)(w * h) / 1000000. * (double)iter / elapsed);
+ fprintf(stderr,
+ " Output bit stream: %f Megabits/sec\n",
+ (double)totalJpegSize * 8. / 1000000. * (double)iter / elapsed);
}
if (tilew == w && tileh == h && doWrite) {
snprintf(tempStr, 1024, "%s_%s_Q%d.jpg", fileName, subName[subsamp],
@@ -467,7 +477,7 @@ static int fullTest(unsigned char *srcBuf, int w, int h, int subsamp,
if (fwrite(jpegBuf[0], jpegSize[0], 1, file) != 1)
_throwunix("writing reference image");
fclose(file); file = NULL;
- if (!quiet) printf("Reference image written to %s\n", tempStr);
+ if (!quiet) fprintf(stderr, "Reference image written to %s\n", tempStr);
}
/* Decompression test */
@@ -549,18 +559,20 @@ static int decompTest(char *fileName)
}
if (quiet == 1) {
- printf("All performance values in Mpixels/sec\n\n");
- printf("Bitmap JPEG JPEG %s %s Xform Comp Decomp ",
- doTile ? "Tile " : "Image", doTile ? "Tile " : "Image");
- if (doYUV) printf("Decode");
- printf("\n");
- printf("Format CS Subsamp Width Height Perf Ratio Perf ");
- if (doYUV) printf("Perf");
- printf("\n\n");
+ fprintf(stderr, "All performance values in Mpixels/sec\n\n");
+ fprintf(stderr,
+ "Bitmap JPEG JPEG %s %s Xform Comp Decomp ",
+ doTile ? "Tile " : "Image", doTile ? "Tile " : "Image");
+ if (doYUV) fprintf(stderr, "Decode");
+ fprintf(stderr, "\n");
+ fprintf(stderr,
+ "Format CS Subsamp Width Height Perf Ratio Perf ");
+ if (doYUV) fprintf(stderr, "Perf");
+ fprintf(stderr, "\n\n");
} else if (!quiet)
- printf(">>>>> JPEG %s --> %s (%s) <<<<<\n",
- formatName(subsamp, cs, tempStr), pixFormatStr[pf],
- (flags & TJFLAG_BOTTOMUP) ? "Bottom-up" : "Top-down");
+ fprintf(stderr, ">>>>> JPEG %s --> %s (%s) <<<<<\n",
+ formatName(subsamp, cs, tempStr), pixFormatStr[pf],
+ (flags & TJFLAG_BOTTOMUP) ? "Bottom-up" : "Top-down");
for (tilew = doTile ? 16 : w, tileh = doTile ? 16 : h; ;
tilew *= 2, tileh *= 2) {
@@ -587,15 +599,16 @@ static int decompTest(char *fileName)
tw = w; th = h; ttilew = tilew; ttileh = tileh;
if (!quiet) {
- printf("\n%s size: %d x %d", doTile ? "Tile" : "Image", ttilew, ttileh);
+ fprintf(stderr, "\n%s size: %d x %d", doTile ? "Tile" : "Image", ttilew,
+ ttileh);
if (sf.num != 1 || sf.denom != 1)
- printf(" --> %d x %d", TJSCALED(tw, sf), TJSCALED(th, sf));
- printf("\n");
+ fprintf(stderr, " --> %d x %d", TJSCALED(tw, sf), TJSCALED(th, sf));
+ fprintf(stderr, "\n");
} else if (quiet == 1) {
- printf("%-4s (%s) %-5s %-5s ", pixFormatStr[pf],
- (flags & TJFLAG_BOTTOMUP) ? "BU" : "TD", csName[cs],
- subNameLong[subsamp]);
- printf("%-5d %-5d ", tilew, tileh);
+ fprintf(stderr, "%-4s (%s) %-5s %-5s ", pixFormatStr[pf],
+ (flags & TJFLAG_BOTTOMUP) ? "BU" : "TD", csName[cs],
+ subNameLong[subsamp]);
+ fprintf(stderr, "%-5d %-5d ", tilew, tileh);
}
tsubsamp = subsamp;
@@ -665,26 +678,28 @@ static int decompTest(char *fileName)
totalJpegSize += jpegSize[tile];
if (quiet) {
- printf("%-6s%s%-6s%s",
- sigfig((double)(w * h) / 1000000. / elapsed, 4, tempStr, 80),
- quiet == 2 ? "\n" : " ",
- sigfig((double)(w * h * ps) / (double)totalJpegSize, 4,
- tempStr2, 80),
- quiet == 2 ? "\n" : " ");
+ fprintf(stderr, "%-6s%s%-6s%s",
+ sigfig((double)(w * h) / 1000000. / elapsed, 4, tempStr, 80),
+ quiet == 2 ? "\n" : " ",
+ sigfig((double)(w * h * ps) / (double)totalJpegSize, 4,
+ tempStr2, 80),
+ quiet == 2 ? "\n" : " ");
} else if (!quiet) {
- printf("Transform --> Frame rate: %f fps\n",
- 1.0 / elapsed);
- printf(" Output image size: %lu bytes\n",
- totalJpegSize);
- printf(" Compression ratio: %f:1\n",
- (double)(w * h * ps) / (double)totalJpegSize);
- printf(" Throughput: %f Megapixels/sec\n",
- (double)(w * h) / 1000000. / elapsed);
- printf(" Output bit stream: %f Megabits/sec\n",
- (double)totalJpegSize * 8. / 1000000. / elapsed);
+ fprintf(stderr, "Transform --> Frame rate: %f fps\n",
+ 1.0 / elapsed);
+ fprintf(stderr, " Output image size: %lu bytes\n",
+ totalJpegSize);
+ fprintf(stderr, " Compression ratio: %f:1\n",
+ (double)(w * h * ps) / (double)totalJpegSize);
+ fprintf(stderr,
+ " Throughput: %f Megapixels/sec\n",
+ (double)(w * h) / 1000000. / elapsed);
+ fprintf(stderr,
+ " Output bit stream: %f Megabits/sec\n",
+ (double)totalJpegSize * 8. / 1000000. / elapsed);
}
} else {
- if (quiet == 1) printf("N/A N/A ");
+ if (quiet == 1) fprintf(stderr, "N/A N/A ");
tjFree(jpegBuf[0]);
jpegBuf[0] = NULL;
decompsrc = 1;
@@ -697,7 +712,7 @@ static int decompTest(char *fileName)
decompsrc ? &srcSize : jpegSize, NULL, tw, th, tsubsamp, 0,
fileName, ttilew, ttileh) == -1)
goto bailout;
- } else if (quiet == 1) printf("N/A\n");
+ } else if (quiet == 1) fprintf(stderr, "N/A\n");
for (i = 0; i < ntilesw * ntilesh; i++) {
tjFree(jpegBuf[i]); jpegBuf[i] = NULL;
@@ -819,7 +834,7 @@ int tjbench(int argc, char *argv[])
decompOnly = 1;
}
- printf("\n");
+ fprintf(stderr, "\n");
if (!decompOnly) {
minArg = 3;
@@ -839,16 +854,16 @@ int tjbench(int argc, char *argv[])
if (!strcasecmp(argv[i], "-tile")) {
doTile = 1; xformOpt |= TJXOPT_CROP;
} else if (!strcasecmp(argv[i], "-fastupsample")) {
- printf("Using fast upsampling code\n\n");
+ fprintf(stderr, "Using fast upsampling code\n\n");
flags |= TJFLAG_FASTUPSAMPLE;
} else if (!strcasecmp(argv[i], "-fastdct")) {
- printf("Using fastest DCT/IDCT algorithm\n\n");
+ fprintf(stderr, "Using fastest DCT/IDCT algorithm\n\n");
flags |= TJFLAG_FASTDCT;
} else if (!strcasecmp(argv[i], "-accuratedct")) {
- printf("Using most accurate DCT/IDCT algorithm\n\n");
+ fprintf(stderr, "Using most accurate DCT/IDCT algorithm\n\n");
flags |= TJFLAG_ACCURATEDCT;
} else if (!strcasecmp(argv[i], "-progressive")) {
- printf("Using progressive entropy coding\n\n");
+ fprintf(stderr, "Using progressive entropy coding\n\n");
flags |= TJFLAG_PROGRESSIVE;
} else if (!strcasecmp(argv[i], "-rgb"))
pf = TJPF_RGB;
@@ -916,13 +931,13 @@ int tjbench(int argc, char *argv[])
if (temp >= 0.0) warmup = temp;
else usage(argv[0]);
- printf("Warmup time = %.1f seconds\n\n", warmup);
+ fprintf(stderr, "Warmup time = %.1f seconds\n\n", warmup);
} else if (!strcasecmp(argv[i], "-alloc"))
flags &= (~TJFLAG_NOREALLOC);
else if (!strcasecmp(argv[i], "-bmp"))
ext = "bmp";
else if (!strcasecmp(argv[i], "-yuv")) {
- printf("Testing YUV planar encoding/decoding\n\n");
+ fprintf(stderr, "Testing YUV planar encoding/decoding\n\n");
doYUV = 1;
} else if (!strcasecmp(argv[i], "-yuvpad") && i < argc - 1) {
int temp = atoi(argv[++i]);
@@ -953,14 +968,14 @@ int tjbench(int argc, char *argv[])
}
if ((sf.num != 1 || sf.denom != 1) && doTile) {
- printf("Disabling tiled compression/decompression tests, because those tests do not\n");
- printf("work when scaled decompression is enabled.\n");
+ fprintf(stderr, "Disabling tiled compression/decompression tests, because those tests do not\n");
+ fprintf(stderr, "work when scaled decompression is enabled.\n");
doTile = 0;
}
if ((flags & TJFLAG_NOREALLOC) == 0 && doTile) {
- printf("Disabling tiled compression/decompression tests, because those tests do not\n");
- printf("work when dynamic JPEG buffer allocation is enabled.\n\n");
+ fprintf(stderr, "Disabling tiled compression/decompression tests, because those tests do not\n");
+ fprintf(stderr, "work when dynamic JPEG buffer allocation is enabled.\n\n");
doTile = 0;
}
@@ -972,44 +987,44 @@ int tjbench(int argc, char *argv[])
}
if (quiet == 1 && !decompOnly) {
- printf("All performance values in Mpixels/sec\n\n");
- printf("Bitmap JPEG JPEG %s %s ",
- doTile ? "Tile " : "Image", doTile ? "Tile " : "Image");
- if (doYUV) printf("Encode ");
- printf("Comp Comp Decomp ");
- if (doYUV) printf("Decode");
- printf("\n");
- printf("Format Subsamp Qual Width Height ");
- if (doYUV) printf("Perf ");
- printf("Perf Ratio Perf ");
- if (doYUV) printf("Perf");
- printf("\n\n");
+ fprintf(stderr, "All performance values in Mpixels/sec\n\n");
+ fprintf(stderr, "Bitmap JPEG JPEG %s %s ",
+ doTile ? "Tile " : "Image", doTile ? "Tile " : "Image");
+ if (doYUV) fprintf(stderr, "Encode ");
+ fprintf(stderr, "Comp Comp Decomp ");
+ if (doYUV) fprintf(stderr, "Decode");
+ fprintf(stderr, "\n");
+ fprintf(stderr, "Format Subsamp Qual Width Height ");
+ if (doYUV) fprintf(stderr, "Perf ");
+ fprintf(stderr, "Perf Ratio Perf ");
+ if (doYUV) fprintf(stderr, "Perf");
+ fprintf(stderr, "\n\n");
}
if (decompOnly) {
decompTest(argv[1]);
- printf("\n");
+ fprintf(stderr, "\n");
goto bailout;
}
if (subsamp >= 0 && subsamp < TJ_NUMSAMP) {
for (i = maxQual; i >= minQual; i--)
fullTest(srcBuf, w, h, subsamp, i, argv[1]);
- printf("\n");
+ fprintf(stderr, "\n");
} else {
if (pf != TJPF_CMYK) {
for (i = maxQual; i >= minQual; i--)
fullTest(srcBuf, w, h, TJSAMP_GRAY, i, argv[1]);
- printf("\n");
+ fprintf(stderr, "\n");
}
for (i = maxQual; i >= minQual; i--)
fullTest(srcBuf, w, h, TJSAMP_420, i, argv[1]);
- printf("\n");
+ fprintf(stderr, "\n");
for (i = maxQual; i >= minQual; i--)
fullTest(srcBuf, w, h, TJSAMP_422, i, argv[1]);
- printf("\n");
+ fprintf(stderr, "\n");
for (i = maxQual; i >= minQual; i--)
fullTest(srcBuf, w, h, TJSAMP_444, i, argv[1]);
- printf("\n");
+ fprintf(stderr, "\n");
}
bailout: