| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <fcntl.h> | 5 #include <fcntl.h> |
| 6 #include <sys/stat.h> | 6 #include <sys/stat.h> |
| 7 #include <sys/time.h> // for timersub macro. | 7 #include <sys/time.h> |
| 8 #include <unistd.h> | 8 #include <unistd.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| 11 #include <cstdio> | 11 #include <cstdio> |
| 12 #include <cstdlib> | 12 #include <cstdlib> |
| 13 #include <cstring> | 13 #include <cstring> |
| 14 | 14 |
| 15 #include "opentype-sanitiser.h" | 15 #include "opentype-sanitiser.h" |
| 16 #include "ots-memory-stream.h" | 16 #include "ots-memory-stream.h" |
| 17 | 17 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 num_repeat = 2500; | 55 num_repeat = 2500; |
| 56 } | 56 } |
| 57 if (st.st_size < 1024 * 100) { | 57 if (st.st_size < 1024 * 100) { |
| 58 num_repeat = 5000; | 58 num_repeat = 5000; |
| 59 } | 59 } |
| 60 | 60 |
| 61 struct timeval start, end, elapsed; | 61 struct timeval start, end, elapsed; |
| 62 ::gettimeofday(&start, 0); | 62 ::gettimeofday(&start, 0); |
| 63 for (int i = 0; i < num_repeat; ++i) { | 63 for (int i = 0; i < num_repeat; ++i) { |
| 64 ots::MemoryStream output(result, st.st_size + kPadLen); | 64 ots::MemoryStream output(result, st.st_size + kPadLen); |
| 65 bool r = ots::Process(&output, data, st.st_size); | 65 ots::OTSContext context; |
| 66 bool r = context.Process(&output, data, st.st_size); |
| 66 if (!r) { | 67 if (!r) { |
| 67 std::fprintf(stderr, "Failed to sanitise file!\n"); | 68 std::fprintf(stderr, "Failed to sanitise file!\n"); |
| 68 return 1; | 69 return 1; |
| 69 } | 70 } |
| 70 } | 71 } |
| 71 ::gettimeofday(&end, 0); | 72 ::gettimeofday(&end, 0); |
| 72 timersub(&end, &start, &elapsed); | 73 timersub(&end, &start, &elapsed); |
| 73 | 74 |
| 74 long long unsigned us | 75 long long unsigned us |
| 75 = ((elapsed.tv_sec * 1000 * 1000) + elapsed.tv_usec) / num_repeat; | 76 = ((elapsed.tv_sec * 1000 * 1000) + elapsed.tv_usec) / num_repeat; |
| 76 std::fprintf(stderr, "%llu [us] %s (%llu bytes, %llu [byte/us])\n", | 77 std::fprintf(stderr, "%llu [us] %s (%llu bytes, %llu [byte/us])\n", |
| 77 us, argv[1], static_cast<long long>(st.st_size), | 78 us, argv[1], static_cast<long long>(st.st_size), |
| 78 (us ? st.st_size / us : 0)); | 79 (us ? st.st_size / us : 0)); |
| 79 | 80 |
| 80 return 0; | 81 return 0; |
| 81 } | 82 } |
| OLD | NEW |