├── .gitignore ├── COPYING ├── Makefile ├── alice29.txt.xz ├── asyoulik.txt.xz ├── benchmark.c ├── cp.html.xz ├── dickens.xz ├── enwik8.xz ├── fields.c.xz ├── fireworks.jpeg.xz ├── geo.protodata.xz ├── grammar.lsp.xz ├── kennedy.xls.xz ├── lcet10.txt.xz ├── mozilla.xz ├── mr.xz ├── nci.xz ├── ooffice.xz ├── osdb.xz ├── paper-100k.pdf.xz ├── plrabn12.txt.xz ├── ptt5.xz ├── reymont.xz ├── samba.xz ├── sao.xz ├── sum.xz ├── timer.c ├── timer.h ├── urls.10K.xz ├── webster.xz ├── x-ray.xz ├── xargs.1.xz └── xml.xz /.gitignore: -------------------------------------------------------------------------------- 1 | *~ 2 | 3 | /benchmark 4 | /data.csv 5 | /result.log 6 | 7 | /alice29.txt 8 | /asyoulik.txt 9 | /cp.html 10 | /dickens 11 | /enwik8 12 | /fields.c 13 | /fireworks.jpeg 14 | /geo.protodata 15 | /grammar.lsp 16 | /kennedy.xls 17 | /lcet10.txt 18 | /mozilla 19 | /mr 20 | /nci 21 | /ooffice 22 | /osdb 23 | /paper-100k.pdf 24 | /plrabn12.txt 25 | /ptt5 26 | /reymont 27 | /samba 28 | /sao 29 | /sum 30 | /urls.10K 31 | /webster 32 | /xargs.1 33 | /xml 34 | /x-ray 35 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2013-2015 The Squash Authors 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | CC=cc 2 | 3 | CANTERBURY = \ 4 | alice29.txt \ 5 | asyoulik.txt \ 6 | cp.html \ 7 | fields.c \ 8 | grammar.lsp \ 9 | kennedy.xls \ 10 | lcet10.txt \ 11 | plrabn12.txt \ 12 | ptt5 \ 13 | sum \ 14 | xargs.1 15 | 16 | SILESA = \ 17 | dickens \ 18 | mozilla \ 19 | mr \ 20 | nci \ 21 | ooffice \ 22 | osdb \ 23 | reymont \ 24 | samba \ 25 | sao \ 26 | webster \ 27 | xml \ 28 | x-ray 29 | 30 | LTCB = \ 31 | enwik8 32 | 33 | SNAPPY = \ 34 | fireworks.jpeg \ 35 | geo.protodata \ 36 | paper-100k.pdf \ 37 | urls.10K 38 | 39 | DATA = \ 40 | $(CANTERBURY) \ 41 | $(SILESA) \ 42 | $(LTCB) \ 43 | $(SNAPPY) 44 | 45 | all: data.csv 46 | 47 | %:: %.xz 48 | squash -kdc xz $^ $@ 49 | 50 | benchmark: benchmark.c timer.c 51 | $(CC) -Wall -Wextra -g -o benchmark $^ `pkg-config --libs --cflags squash-0.8` 52 | 53 | data.csv: benchmark $(DATA) 54 | @if [ -e /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor -a "`cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor`" != "performance" ]; then echo -e "WARNING: You should switch to the 'performance' CPU governor by running\n\n\tsu -c 'echo performance | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor'\n"; fi 55 | ./benchmark -o $@ $(sort $(DATA)) 2>&1 | tee result.log 56 | -------------------------------------------------------------------------------- /alice29.txt.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/alice29.txt.xz -------------------------------------------------------------------------------- /asyoulik.txt.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/asyoulik.txt.xz -------------------------------------------------------------------------------- /benchmark.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013-2016 The Squash Authors 2 | * 3 | * Permission is hereby granted, free of charge, to any person 4 | * obtaining a copy of this software and associated documentation 5 | * files (the "Software"), to deal in the Software without 6 | * restriction, including without limitation the rights to use, copy, 7 | * modify, merge, publish, distribute, sublicense, and/or sell copies 8 | * of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be 12 | * included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 18 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * Authors: 24 | * Evan Nemerson 25 | */ 26 | 27 | #if !defined(__gnu_linux__) 28 | #define SQUASH_BENCHMARK_NO_MEMFD 29 | #endif 30 | 31 | #if !defined(SQUASH_BENCHMARK_NO_MEMFD) 32 | #define _GNU_SOURCE 33 | #include 34 | #endif 35 | 36 | #include 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | 47 | #include 48 | #include "timer.h" 49 | 50 | static double min_exec_time = 5.0; 51 | 52 | static FILE* squash_tmpfile (const char* name); 53 | static FILE* 54 | squash_tmpfile (const char* name) { 55 | #if defined(SQUASH_BENCHMARK_NO_MEMFD) 56 | return tmpfile (); 57 | #else 58 | int fd = syscall (SYS_memfd_create, name, 0); 59 | if (fd == -1) 60 | return tmpfile (); 61 | return fdopen (fd, "w+"); 62 | #endif 63 | } 64 | 65 | static void 66 | print_help_and_exit (const char* executable, int exit_code) { 67 | fprintf (stdout, "Usage: %s [OPTION]... FILE...\n", executable); 68 | fprintf (stdout, "Benchmark Squash plugins.\n"); 69 | fprintf (stdout, "\n"); 70 | fprintf (stdout, "Options:\n"); 71 | fprintf (stdout, "\t-h Print this help screen and exit.\n"); 72 | fprintf (stdout, "\t-c codec Benchmark the specified codec and exit.\n"); 73 | fprintf (stdout, "\t-o outfile CSV output file.\n"); 74 | fprintf (stdout, "\t-t time Minumum execution time in seconds(default: 5.0)\n"); 75 | 76 | exit (exit_code); 77 | } 78 | 79 | struct BenchmarkContext { 80 | FILE* input; 81 | FILE* csv; 82 | char* input_name; 83 | long input_size; 84 | }; 85 | 86 | typedef struct { 87 | long int compressed_size; 88 | double compress_cpu; 89 | double compress_wall; 90 | double decompress_cpu; 91 | double decompress_wall; 92 | } SquashBenchmarkResult; 93 | 94 | static bool 95 | benchmark_codec_with_options (struct BenchmarkContext* context, SquashCodec* codec, SquashOptions* opts) { 96 | SquashBenchmarkResult result = { 0, 0.0, 0.0, 0.0, 0.0 }; 97 | bool success = false; 98 | SquashStatus res = SQUASH_OK; 99 | const int level = squash_options_get_int (opts, codec, "level"); 100 | 101 | #if !defined(SQUASH_BENCHMARK_NO_FORK) 102 | char fifo_name[] = ".squash-benchmark-fifo-XXXXXX"; 103 | 104 | assert (mkfifo (mktemp (fifo_name), 0600) == 0); 105 | 106 | if (fork () == 0) { 107 | int out_descriptor = open (fifo_name, O_WRONLY); 108 | #else 109 | int descriptors[2]; 110 | assert (pipe (descriptors) == 0); 111 | int out_descriptor = descriptors[1]; 112 | #endif 113 | FILE* compressed = squash_tmpfile ("squash-benchmark-compressed"); 114 | FILE* decompressed = squash_tmpfile ("squash-benchmark-decompressed"); 115 | SquashTimer* timer = squash_timer_new (); 116 | int iterations = 0; 117 | 118 | if (level < 0) { 119 | fputs (" compressing: ", stdout); 120 | } else { 121 | fprintf (stdout, " level %d: ", level); 122 | } 123 | 124 | if (fseek (context->input, 0, SEEK_SET) != 0) { 125 | perror ("Unable to seek to beginning of input file"); 126 | exit (-1); 127 | } 128 | 129 | for ( iterations = 0 ; squash_timer_get_elapsed_cpu (timer) < min_exec_time ; iterations++ ) { 130 | fseek (context->input, 0, SEEK_SET); 131 | fseek (compressed, 0, SEEK_SET); 132 | 133 | rewind (compressed); 134 | squash_timer_start (timer); 135 | res = squash_splice_with_options (codec, SQUASH_STREAM_COMPRESS, compressed, context->input, 0, opts); 136 | squash_timer_stop (timer); 137 | rewind (context->input); 138 | 139 | if (res != SQUASH_OK) { 140 | fprintf (stderr, "ERROR: %s (%d) squash_splice_with_options (%s, compress, %p, %p, 0, %p)\n", squash_status_to_string (res), res, squash_codec_get_name (codec), compressed, context->input, opts); 141 | break; 142 | } 143 | } 144 | 145 | if (res == SQUASH_OK) { 146 | result.compressed_size = ftell (compressed); 147 | result.compress_cpu = squash_timer_get_elapsed_cpu (timer) / iterations; 148 | result.compress_wall = squash_timer_get_elapsed_wall (timer) / iterations; 149 | squash_timer_reset (timer); 150 | 151 | if (result.compressed_size == 0) { 152 | fprintf (stdout, "failed (0 byte output, %s [%d]).\n", squash_status_to_string (res), res); 153 | } else { 154 | fprintf (stdout, "compressed (%.6fs CPU, %.6fs wall, %ld bytes)... ", 155 | result.compress_cpu, 156 | result.compress_wall, 157 | result.compressed_size); 158 | 159 | for ( iterations = 0 ; squash_timer_get_elapsed_cpu (timer) < min_exec_time ; iterations++ ) { 160 | fseek (compressed, 0, SEEK_SET); 161 | fseek (decompressed, 0, SEEK_SET); 162 | 163 | squash_timer_start (timer); 164 | res = squash_splice_with_options (codec, SQUASH_STREAM_DECOMPRESS, decompressed, compressed, 0, opts); 165 | squash_timer_stop (timer); 166 | rewind (compressed); 167 | 168 | if (res != SQUASH_OK) { 169 | break; 170 | } 171 | } 172 | 173 | if (res != SQUASH_OK) { 174 | fprintf (stderr, "Failed (%s [%d]).\n", squash_status_to_string (res), res); 175 | } else { 176 | result.decompress_cpu = squash_timer_get_elapsed_cpu (timer) / iterations; 177 | result.decompress_wall = squash_timer_get_elapsed_wall (timer) / iterations; 178 | squash_timer_reset (timer); 179 | 180 | if (ftell (decompressed) != context->input_size) { 181 | /* Should never happen. */ 182 | fprintf (stderr, "Failed (size mismatch; expected %ld, got %ld.\n", context->input_size, ftell (decompressed)); 183 | } else { 184 | fprintf (stdout, "decompressed (%.6fs CPU, %.6fs wall).\n", 185 | result.decompress_cpu, 186 | result.decompress_wall); 187 | 188 | write (out_descriptor, &result, sizeof (SquashBenchmarkResult)); 189 | } 190 | } 191 | } 192 | } 193 | 194 | squash_timer_free (timer); 195 | fclose (compressed); 196 | fclose (decompressed); 197 | 198 | close (out_descriptor); 199 | #if !defined(SQUASH_BENCHMARK_NO_FORK) 200 | exit (0); 201 | } else { 202 | int in_descriptor = open (fifo_name, O_RDONLY); 203 | #else 204 | int in_descriptor = descriptors[0]; 205 | #endif 206 | size_t bytes_read = read (in_descriptor, &result, sizeof (SquashBenchmarkResult)); 207 | wait (NULL); 208 | if (bytes_read == sizeof (SquashBenchmarkResult)) { 209 | if (context->csv != NULL) { 210 | if (level >= 0) { 211 | fprintf (context->csv, "%s,%s,%s,%d,%ld,%ld,%f,%f,%f,%f\r\n", 212 | context->input_name, 213 | squash_plugin_get_name (squash_codec_get_plugin (codec)), 214 | squash_codec_get_name (codec), 215 | level, 216 | context->input_size, 217 | result.compressed_size, 218 | result.compress_cpu, 219 | result.compress_wall, 220 | result.decompress_cpu, 221 | result.decompress_wall); 222 | } else { 223 | fprintf (context->csv, "%s,%s,%s,,%ld,%ld,%f,%f,%f,%f\r\n", 224 | context->input_name, 225 | squash_plugin_get_name (squash_codec_get_plugin (codec)), 226 | squash_codec_get_name (codec), 227 | context->input_size, 228 | result.compressed_size, 229 | result.compress_cpu, 230 | result.compress_wall, 231 | result.decompress_cpu, 232 | result.decompress_wall); 233 | } 234 | } 235 | 236 | success = true; 237 | } 238 | close (in_descriptor); 239 | #if !defined(SQUASH_BENCHMARK_NO_FORK) 240 | unlink (fifo_name); 241 | } 242 | #endif 243 | 244 | return success; 245 | } 246 | 247 | static void 248 | benchmark_codec (SquashCodec* codec, void* data) { 249 | struct BenchmarkContext* context = (struct BenchmarkContext*) data; 250 | SquashOptions* opts; 251 | int level = 0; 252 | char level_s[4]; 253 | bool have_results = false; 254 | 255 | umask (0100); 256 | 257 | fprintf (stdout, " %s:%s\n", 258 | squash_plugin_get_name (squash_codec_get_plugin (codec)), 259 | squash_codec_get_name (codec)); 260 | 261 | opts = squash_options_new (codec, NULL); 262 | if (opts != NULL) { 263 | squash_object_ref_sink (opts); 264 | for ( level = 0 ; level <= 999 ; level++ ) { 265 | snprintf (level_s, 4, "%d", level); 266 | if (squash_options_parse_option (opts, "level", level_s) == SQUASH_OK) { 267 | if (benchmark_codec_with_options (context, codec, opts)) { 268 | have_results = true; 269 | } 270 | } 271 | } 272 | squash_object_unref (opts); 273 | } 274 | 275 | if (!have_results) { 276 | benchmark_codec_with_options (context, codec, NULL); 277 | } 278 | } 279 | 280 | static void 281 | benchmark_plugin (SquashPlugin* plugin, void* data) { 282 | /* Since we're often running against the source dir, we will pick up 283 | plugins which have not been compiled. This should bail us out 284 | before trying to actually use them. */ 285 | if (squash_plugin_init (plugin) != SQUASH_OK) { 286 | return; 287 | } 288 | 289 | squash_plugin_foreach_codec (plugin, benchmark_codec, data); 290 | } 291 | 292 | static SquashCodec* 293 | benchmark_parse_codec (const char* str, SquashOptions** options) { 294 | SquashCodec* codec; 295 | char* s = strdup (str); 296 | char* sp_outer = NULL; 297 | char* sp_inner = NULL; 298 | char* cur_opt = NULL; 299 | char* cur_key = NULL; 300 | char* cur_val = NULL; 301 | SquashStatus res; 302 | 303 | char* name = strtok_r (s, "/", &sp_outer); 304 | codec = squash_get_codec (name); 305 | if (codec == NULL) 306 | return NULL; 307 | 308 | while ((cur_opt = strtok_r (NULL, ",", &sp_outer)) != NULL) { 309 | if (*options == NULL) { 310 | assert (codec != NULL); 311 | *options = squash_options_new (codec, NULL); 312 | squash_object_ref_sink (*options); 313 | } 314 | 315 | cur_key = strtok_r (cur_opt, "=", &sp_inner); 316 | cur_val = strtok_r (NULL, "=", &sp_inner); 317 | 318 | if (cur_val == NULL) { 319 | cur_val = cur_key; 320 | cur_key = "level"; 321 | } 322 | 323 | assert (*options != NULL); 324 | res = squash_options_parse_option (*options, cur_key, cur_val); 325 | if (res != SQUASH_OK) { 326 | fprintf (stderr, "Unable to parse options: %s (%d)\n", squash_status_to_string (res), res); 327 | exit (EXIT_FAILURE); 328 | } 329 | } 330 | 331 | free (s); 332 | 333 | return codec; 334 | } 335 | 336 | int main (int argc, char** argv) { 337 | struct BenchmarkContext context = { NULL, NULL, NULL, 0 }; 338 | int opt; 339 | int optc = 0; 340 | SquashCodec* codec = NULL; 341 | SquashOptions* opts = NULL; 342 | 343 | setvbuf (stdout, NULL, _IONBF, 0); 344 | 345 | while ( (opt = getopt(argc, argv, "hc:o:t:")) != -1 ) { 346 | switch ( opt ) { 347 | case 'h': 348 | print_help_and_exit (argv[0], 0); 349 | break; 350 | case 'o': 351 | context.csv = fopen (optarg, "w+b"); 352 | if (context.csv == NULL) { 353 | perror ("Unable to open output file"); 354 | return -1; 355 | } 356 | setbuf (context.csv, NULL); 357 | break; 358 | case 'c': 359 | codec = benchmark_parse_codec (optarg, &opts); 360 | if (codec == NULL) { 361 | fprintf (stderr, "Unable to find codec.\n"); 362 | return -1; 363 | } 364 | break; 365 | case 't': 366 | min_exec_time = strtod (optarg, NULL); 367 | break; 368 | } 369 | 370 | optc++; 371 | } 372 | 373 | if ( optind >= argc ) { 374 | fputs ("No input files specified.\n", stderr); 375 | return -1; 376 | } 377 | 378 | if (context.csv != NULL) 379 | fprintf (context.csv, "dataset,plugin,codec,level,raw_size,compressed_size,compress_cpu,compress_wall,decompress_cpu,decompress_wall\r\n"); 380 | 381 | while ( optind < argc ) { 382 | context.input_name = argv[optind]; 383 | context.input = fopen (context.input_name, "rb"); 384 | if (context.input == NULL) { 385 | perror ("Unable to open input data"); 386 | return -1; 387 | } 388 | 389 | if (fseek (context.input, 0, SEEK_END) != 0) { 390 | perror ("Unable to seek to end of input file"); 391 | exit (-1); 392 | } 393 | context.input_size = ftell (context.input); 394 | 395 | fprintf (stdout, "Using %s:\n", context.input_name); 396 | 397 | if (opts != NULL) { 398 | benchmark_codec_with_options (&context, codec, opts); 399 | } else if (codec == NULL) { 400 | squash_foreach_plugin (benchmark_plugin, &context); 401 | } else { 402 | benchmark_codec (codec, &context); 403 | } 404 | 405 | optind++; 406 | } 407 | 408 | if (context.csv != NULL) { 409 | fclose (context.csv); 410 | } 411 | fclose (context.input); 412 | 413 | return 0; 414 | } 415 | -------------------------------------------------------------------------------- /cp.html.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/cp.html.xz -------------------------------------------------------------------------------- /dickens.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/dickens.xz -------------------------------------------------------------------------------- /enwik8.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/enwik8.xz -------------------------------------------------------------------------------- /fields.c.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/fields.c.xz -------------------------------------------------------------------------------- /fireworks.jpeg.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/fireworks.jpeg.xz -------------------------------------------------------------------------------- /geo.protodata.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/geo.protodata.xz -------------------------------------------------------------------------------- /grammar.lsp.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/grammar.lsp.xz -------------------------------------------------------------------------------- /kennedy.xls.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/kennedy.xls.xz -------------------------------------------------------------------------------- /lcet10.txt.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/lcet10.txt.xz -------------------------------------------------------------------------------- /mozilla.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/mozilla.xz -------------------------------------------------------------------------------- /mr.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/mr.xz -------------------------------------------------------------------------------- /nci.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/nci.xz -------------------------------------------------------------------------------- /ooffice.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/ooffice.xz -------------------------------------------------------------------------------- /osdb.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/osdb.xz -------------------------------------------------------------------------------- /paper-100k.pdf.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/paper-100k.pdf.xz -------------------------------------------------------------------------------- /plrabn12.txt.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/plrabn12.txt.xz -------------------------------------------------------------------------------- /ptt5.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/ptt5.xz -------------------------------------------------------------------------------- /reymont.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/reymont.xz -------------------------------------------------------------------------------- /samba.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/samba.xz -------------------------------------------------------------------------------- /sao.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/sao.xz -------------------------------------------------------------------------------- /sum.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/sum.xz -------------------------------------------------------------------------------- /timer.c: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 The Squash Authors 2 | * 3 | * Permission is hereby granted, free of charge, to any person 4 | * obtaining a copy of this software and associated documentation 5 | * files (the "Software"), to deal in the Software without 6 | * restriction, including without limitation the rights to use, copy, 7 | * modify, merge, publish, distribute, sublicense, and/or sell copies 8 | * of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be 12 | * included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 18 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * Authors: 24 | * Evan Nemerson 25 | */ 26 | 27 | #define _POSIX_C_SOURCE 199309L 28 | 29 | #include "timer.h" 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #define SQUASH_TIMER_METHOD_CLOCK_GETTIME 0 37 | #define SQUASH_TIMER_METHOD_GETRUSAGE 1 38 | #define SQUASH_TIMER_METHOD_CLOCK 2 39 | #define SQUASH_TIMER_METHOD_GETPROCESSTIMES 3 40 | 41 | #ifdef _WIN32 42 | # define SQUASH_TIMER_METHOD SQUASH_TIMER_METHOD_GETPROCESSTIMES 43 | # include 44 | #endif 45 | 46 | #if !defined(SQUASH_TIMER_METHOD) && (_POSIX_TIMERS > 0) 47 | # ifdef _POSIX_CPUTIME 48 | # define SQUASH_TIMER_CPUTIME CLOCK_PROCESS_CPUTIME_ID 49 | # define SQUASH_TIMER_METHOD SQUASH_TIMER_METHOD_CLOCK_GETTIME 50 | # include 51 | # elif defined(CLOCK_VIRTUAL) 52 | # define SQUASH_TIMER_CPUTIME CLOCK_VIRTUAL 53 | # define SQUASH_TIMER_METHOD SQUASH_TIMER_METHOD_CLOCK_GETTIME 54 | # include 55 | # endif 56 | #endif 57 | 58 | #if !defined(SQUASH_TIMER_METHOD) 59 | # define SQUASH_TIMER_METHOD SQUASH_TIMER_METHOD_GETRUSAGE 60 | # include 61 | # include 62 | #endif 63 | 64 | struct SquashTimer_s { 65 | double elapsed_cpu; 66 | double elapsed_wall; 67 | 68 | #if SQUASH_TIMER_METHOD == SQUASH_TIMER_METHOD_CLOCK_GETTIME 69 | struct timespec start_wall; 70 | struct timespec end_wall; 71 | struct timespec start_cpu; 72 | struct timespec end_cpu; 73 | #elif SQUASH_TIMER_METHOD == SQUASH_TIMER_METHOD_GETRUSAGE 74 | struct timeval start_wall; 75 | struct timeval end_wall; 76 | struct rusage start_cpu; 77 | struct rusage end_cpu; 78 | #elif SQUASH_TIMER_METHOD == SQUASH_TIMER_METHOD_GETPROCESSTIMES 79 | ULONGLONG start_wall; 80 | ULONGLONG end_wall; 81 | FILETIME start_cpu; 82 | FILETIME end_cpu; 83 | #endif 84 | }; 85 | 86 | /** 87 | * @defgroup SquashTimer SquashTimer 88 | * @brief A cross-platform timer 89 | * 90 | * @{ 91 | */ 92 | 93 | /** 94 | * @struct _SquashTimer 95 | * @brief Simple cross-platform timer 96 | * 97 | * Provides a timer for measuring the elapsed time between events, in 98 | * both wall-clock and CPU time. 99 | */ 100 | 101 | /** 102 | * @brief Create a new timer. 103 | * 104 | * Note that this function does not actually start timing. 105 | * 106 | * @return A new timer instance, or *NULL* on failure. 107 | * @see squash_timer_free 108 | */ 109 | SquashTimer* 110 | squash_timer_new (void) { 111 | SquashTimer* timer = (SquashTimer*) malloc (sizeof (SquashTimer)); 112 | squash_timer_reset (timer); 113 | return timer; 114 | } 115 | 116 | /** 117 | * @brief Free a timer. 118 | * 119 | * @param timer The timer. 120 | */ 121 | void 122 | squash_timer_free (SquashTimer* timer) { 123 | free (timer); 124 | } 125 | 126 | /** 127 | * @brief Begin or continue timing. 128 | * 129 | * @param timer The timer. 130 | */ 131 | void 132 | squash_timer_start (SquashTimer* timer) { 133 | #if SQUASH_TIMER_METHOD == SQUASH_TIMER_METHOD_CLOCK_GETTIME 134 | if (clock_gettime (CLOCK_REALTIME, &(timer->start_wall)) != 0) { 135 | fputs ("Unable to get wall clock time\n", stderr); 136 | exit (-1); 137 | } 138 | if (clock_gettime (SQUASH_TIMER_CPUTIME, &(timer->start_cpu)) != 0) { 139 | fputs ("Unable to get CPU clock time\n", stderr); 140 | exit (-1); 141 | } 142 | #elif SQUASH_TIMER_METHOD == SQUASH_TIMER_METHOD_GETRUSAGE 143 | if (gettimeofday(&(timer->start_wall), NULL) != 0) { 144 | fputs ("Unable to get time\n", stderr); 145 | } 146 | if (getrusage(RUSAGE_SELF, &(timer->start_cpu)) != 0) { 147 | fputs ("Unable to get CPU clock time\n", stderr); 148 | exit (-1); 149 | } 150 | #elif SQUASH_TIMER_METHOD == SQUASH_TIMER_METHOD_GETPROCESSTIMES 151 | #if _WIN32_WINNT >= 0x0600 152 | timer->start_wall = GetTickCount64 (); 153 | #else 154 | timer->start_wall = GetTickCount (); 155 | #endif 156 | FILETIME CreationTime, ExitTime, KernelTime; 157 | if (!GetProcessTimes (GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &(timer->start_cpu))) { 158 | fputs ("Unable to get CPU clock time\n", stderr); 159 | } 160 | #endif 161 | } 162 | 163 | #if SQUASH_TIMER_METHOD == SQUASH_TIMER_METHOD_CLOCK_GETTIME 164 | static double 165 | squash_timer_timespec_elapsed (struct timespec* start, struct timespec* end) { 166 | return 167 | (double) (end->tv_sec - start->tv_sec) + 168 | (((double) (end->tv_nsec - start->tv_nsec)) / 1000000000); 169 | } 170 | #elif SQUASH_TIMER_METHOD == SQUASH_TIMER_METHOD_GETRUSAGE 171 | static double 172 | squash_timer_timeval_elapsed (struct timeval* start, struct timeval* end) { 173 | return 174 | (double) (end->tv_sec - start->tv_sec) + 175 | (((double) (end->tv_usec - start->tv_usec)) / 1000000); 176 | } 177 | 178 | static double 179 | squash_timer_rusage_elapsed (struct rusage* start, struct rusage* end) { 180 | return 181 | (double) ((end->ru_utime.tv_sec + end->ru_stime.tv_sec) - (start->ru_utime.tv_sec + start->ru_stime.tv_sec)) + 182 | (((double) ((end->ru_utime.tv_usec + end->ru_stime.tv_usec) - (start->ru_utime.tv_usec + start->ru_stime.tv_usec))) / 1000000); 183 | } 184 | #endif 185 | 186 | /** 187 | * @brief Stop timing. 188 | * 189 | * @param timer The timer. 190 | */ 191 | void 192 | squash_timer_stop (SquashTimer* timer) { 193 | #if SQUASH_TIMER_METHOD == SQUASH_TIMER_METHOD_CLOCK_GETTIME 194 | if (clock_gettime (SQUASH_TIMER_CPUTIME, &(timer->end_cpu)) != 0) { 195 | fputs ("Unable to get CPU clock time\n", stderr); 196 | exit (-1); 197 | } 198 | if (clock_gettime (CLOCK_REALTIME, &(timer->end_wall)) != 0) { 199 | fputs ("Unable to get wall clock time\n", stderr); 200 | exit (-1); 201 | } 202 | 203 | timer->elapsed_cpu += squash_timer_timespec_elapsed (&(timer->start_cpu), &(timer->end_cpu)); 204 | timer->elapsed_wall += squash_timer_timespec_elapsed (&(timer->start_wall), &(timer->end_wall)); 205 | #elif SQUASH_TIMER_METHOD == SQUASH_TIMER_METHOD_GETRUSAGE 206 | if (getrusage(RUSAGE_SELF, &(timer->end_cpu)) != 0) { 207 | fputs ("Unable to get CPU clock time\n", stderr); 208 | exit (-1); 209 | } 210 | if (gettimeofday(&(timer->end_wall), NULL) != 0) { 211 | fputs ("Unable to get time\n", stderr); 212 | exit (-1); 213 | } 214 | 215 | timer->elapsed_cpu += squash_timer_rusage_elapsed (&(timer->start_cpu), &(timer->end_cpu)); 216 | timer->elapsed_wall += squash_timer_timeval_elapsed (&(timer->start_wall), &(timer->end_wall)); 217 | #elif SQUASH_TIMER_METHOD == SQUASH_TIMER_METHOD_GETPROCESSTIMES 218 | FILETIME CreationTime, ExitTime, KernelTime; 219 | if (!GetProcessTimes (GetCurrentProcess(), &CreationTime, &ExitTime, &KernelTime, &(timer->end_cpu))) { 220 | fputs ("Unable to get CPU clock time\n", stderr); 221 | } 222 | 223 | #if _WIN32_WINNT >= 0x0600 224 | timer->end_wall = GetTickCount64 (); 225 | #else 226 | timer->end_wall = GetTickCount (); 227 | if (timer->end_wall < timer->start_wall) { 228 | timer->end_wall += 0xffffffff; 229 | } 230 | #endif 231 | 232 | uint64_t start_cpu, end_cpu; 233 | 234 | start_cpu = timer->start_cpu.dwHighDateTime; 235 | start_cpu <<= sizeof (DWORD) * 8; 236 | start_cpu |= timer->start_cpu.dwLowDateTime; 237 | 238 | end_cpu = timer->end_cpu.dwHighDateTime; 239 | end_cpu <<= sizeof (DWORD) * 8; 240 | end_cpu |= timer->end_cpu.dwLowDateTime; 241 | 242 | timer->elapsed_cpu += ((double) (end_cpu - start_cpu)) / 10000000; 243 | timer->elapsed_wall += ((double) (timer->end_wall - timer->start_wall)) / 1000; 244 | #endif 245 | } 246 | 247 | /** 248 | * @brief Reset the timer. 249 | * 250 | * Resets the elapsed time to 0. 251 | * 252 | * @param timer The timer. 253 | */ 254 | void 255 | squash_timer_reset (SquashTimer* timer) { 256 | timer->elapsed_cpu = 0.0; 257 | timer->elapsed_wall = 0.0; 258 | } 259 | 260 | /** 261 | * @brief Restart the timer. 262 | * 263 | * This is a convenience wrapper for resetting the timer then starting 264 | * it. 265 | * 266 | * @param timer The timer. 267 | */ 268 | void 269 | squash_timer_restart (SquashTimer* timer) { 270 | squash_timer_reset (timer); 271 | squash_timer_start (timer); 272 | } 273 | 274 | /** 275 | * @brief Get the elapsed CPU time. 276 | * 277 | * @param timer The timer. 278 | * @return Number of seconds (CPU time) elapsed. 279 | */ 280 | double 281 | squash_timer_get_elapsed_cpu (SquashTimer* timer) { 282 | return timer->elapsed_cpu; 283 | } 284 | 285 | /** 286 | * @brief Get the elapsed wall-clock time. 287 | * 288 | * @param timer The timer. 289 | * @return Number of seconds (wall-clock time) elapsed. 290 | */ 291 | double 292 | squash_timer_get_elapsed_wall (SquashTimer* timer) { 293 | return timer->elapsed_wall; 294 | } 295 | 296 | /** 297 | * @} 298 | */ 299 | -------------------------------------------------------------------------------- /timer.h: -------------------------------------------------------------------------------- 1 | /* Copyright (c) 2013 The Squash Authors 2 | * 3 | * Permission is hereby granted, free of charge, to any person 4 | * obtaining a copy of this software and associated documentation 5 | * files (the "Software"), to deal in the Software without 6 | * restriction, including without limitation the rights to use, copy, 7 | * modify, merge, publish, distribute, sublicense, and/or sell copies 8 | * of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be 12 | * included in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 18 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 19 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | * SOFTWARE. 22 | * 23 | * Authors: 24 | * Evan Nemerson 25 | */ 26 | 27 | #ifndef SQUASH_TIMER_H 28 | #define SQUASH_TIMER_H 29 | 30 | typedef struct SquashTimer_s SquashTimer; 31 | 32 | SquashTimer* squash_timer_new (void); 33 | void squash_timer_free (SquashTimer* timer); 34 | 35 | void squash_timer_start (SquashTimer* timer); 36 | void squash_timer_stop (SquashTimer* timer); 37 | void squash_timer_reset (SquashTimer* timer); 38 | void squash_timer_restart (SquashTimer* timer); 39 | 40 | double squash_timer_get_elapsed_cpu (SquashTimer* timer); 41 | double squash_timer_get_elapsed_wall (SquashTimer* timer); 42 | 43 | #endif /* SQUASH_TIMER_H */ 44 | -------------------------------------------------------------------------------- /urls.10K.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/urls.10K.xz -------------------------------------------------------------------------------- /webster.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/webster.xz -------------------------------------------------------------------------------- /x-ray.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/x-ray.xz -------------------------------------------------------------------------------- /xargs.1.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/xargs.1.xz -------------------------------------------------------------------------------- /xml.xz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/quixdb/squash-benchmark/37ee14532dea32ffd6145eec5ab5a4ed85896f4f/xml.xz --------------------------------------------------------------------------------