Add -nowrite arg to TJBench to improve consistency

Prevents any images from being written to disk, thus making the
performance of the benchmark as CPU-bound as possible.
This commit is contained in:
DRC
2016-01-11 22:27:38 -06:00
parent 368cd52d38
commit eb59b6e72d
3 changed files with 24 additions and 10 deletions

View File

@@ -52,6 +52,11 @@ Since the macro is used only internally, it has been moved into jconfigint.h.
JSIMD_FORCENONE environment variable to 1 (the other SIMD implementations
already had this capability.)
[11] Added a new command-line argument to TJBench (-nowrite) that prevents the
benchmark from outputting any images. This removes any potential operating
system overhead that might be caused by lazy writes to disk and thus improves
the consistency of the performance measurements.
1.4.2
=====

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C)2009-2014 D. R. Commander. All Rights Reserved.
* Copyright (C)2009-2014, 2016 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -35,7 +35,7 @@ import org.libjpegturbo.turbojpeg.*;
class TJBench {
static int flags = 0, quiet = 0, pf = TJ.PF_BGR, yuvpad = 1, warmup = 1;
static boolean compOnly, decompOnly, doTile, doYUV;
static boolean compOnly, decompOnly, doTile, doYUV, write;
static final String[] pixFormatStr = {
"RGB", "BGR", "RGBX", "BGRX", "XBGR", "XRGB", "GRAY"
@@ -223,6 +223,8 @@ class TJBench {
}
}
if (!write) return;
if (sf.getNum() != 1 || sf.getDenom() != 1)
sizeStr = new String(sf.getNum() + "_" + sf.getDenom());
else if (tilew != w || tileh != h)
@@ -394,7 +396,7 @@ class TJBench {
System.out.format(" Output bit stream: %f Megabits/sec\n",
(double)totalJpegSize * 8. / 1000000. * (double)iter / elapsed);
}
if (tilew == w && tileh == h) {
if (tilew == w && tileh == h && write) {
String tempStr = fileName + "_" + subName[subsamp] + "_" + "Q" +
jpegQual + ".jpg";
FileOutputStream fos = new FileOutputStream(tempStr);
@@ -659,7 +661,9 @@ class TJBench {
System.out.println("-benchtime <t> = Run each benchmark for at least <t> seconds (default = 5.0)");
System.out.println("-warmup <w> = Execute each benchmark <w> times to prime the cache before");
System.out.println(" taking performance measurements (default = 1)");
System.out.println("-componly = Stop after running compression tests. Do not test decompression.\n");
System.out.println("-componly = Stop after running compression tests. Do not test decompression.");
System.out.println("-nowrite = Do not write reference or output images (improves consistency");
System.out.println(" of performance measurements.)\n");
System.out.println("NOTE: If the quality is specified as a range (e.g. 90-100), a separate");
System.out.println("test will be performed for all quality values in the range.\n");
System.exit(1);
@@ -817,6 +821,8 @@ class TJBench {
}
if (argv[i].equalsIgnoreCase("-componly"))
compOnly = true;
if (argv[i].equalsIgnoreCase("-nowrite"))
write = false;
if (argv[i].equalsIgnoreCase("-warmup") && i < argv.length - 1) {
int temp = -1;
try {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C)2009-2015 D. R. Commander. All Rights Reserved.
* Copyright (C)2009-2016 D. R. Commander. All Rights Reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -46,7 +46,7 @@
#define _throwbmp(m) _throw(m, bmpgeterr())
int flags=TJFLAG_NOREALLOC, componly=0, decomponly=0, doyuv=0, quiet=0,
dotile=0, pf=TJPF_BGR, yuvpad=1, warmup=1;
dotile=0, pf=TJPF_BGR, yuvpad=1, warmup=1, write=1;
char *ext="ppm";
const char *pixFormatStr[TJ_NUMPF]=
{
@@ -224,7 +224,7 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf,
snprintf(tempstr, 1024, "%s_%s%s_%s.%s", filename, subName[subsamp],
qualstr, sizestr, ext);
if(savebmp(tempstr, dstbuf, scaledw, scaledh, pf,
if(write && savebmp(tempstr, dstbuf, scaledw, scaledh, pf,
(flags&TJFLAG_BOTTOMUP)!=0)==-1)
_throwbmp("saving bitmap");
ptr=strrchr(tempstr, '.');
@@ -259,7 +259,7 @@ int decomp(unsigned char *srcbuf, unsigned char **jpegbuf,
dstbuf[pitch*row+col]
=abs(dstbuf[pitch*row+col]-srcbuf[pitch*row+col]);
}
if(savebmp(tempstr, dstbuf, w, h, pf,
if(write && savebmp(tempstr, dstbuf, w, h, pf,
(flags&TJFLAG_BOTTOMUP)!=0)==-1)
_throwbmp("saving bitmap");
}
@@ -422,7 +422,7 @@ int fullTest(unsigned char *srcbuf, int w, int h, int subsamp, int jpegqual,
printf(" Output bit stream: %f Megabits/sec\n",
(double)totaljpegsize*8./1000000.*(double)iter/elapsed);
}
if(tilew==w && tileh==h)
if(tilew==w && tileh==h && write)
{
snprintf(tempstr, 1024, "%s_%s_Q%d.jpg", filename, subName[subsamp],
jpegqual);
@@ -756,7 +756,9 @@ void usage(char *progname)
printf("-benchtime <t> = Run each benchmark for at least <t> seconds (default = 5.0)\n");
printf("-warmup <w> = Execute each benchmark <w> times to prime the cache before\n");
printf(" taking performance measurements (default = 1)\n");
printf("-componly = Stop after running compression tests. Do not test decompression.\n\n");
printf("-componly = Stop after running compression tests. Do not test decompression.\n");
printf("-nowrite = Do not write reference or output images (improves consistency of\n");
printf(" performance measurements.)\n\n");
printf("NOTE: If the quality is specified as a range (e.g. 90-100), a separate\n");
printf("test will be performed for all quality values in the range.\n\n");
exit(1);
@@ -906,6 +908,7 @@ int main(int argc, char *argv[])
}
}
if(!strcasecmp(argv[i], "-componly")) componly=1;
if(!strcasecmp(argv[i], "-nowrite")) write=0;
}
}