aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2012-02-07 15:52:17 -0800
committerAlon Zakai <alonzakai@gmail.com>2012-02-07 15:52:17 -0800
commitc3e992c15d5aa3ff6e36f51818845fadb32fa60c (patch)
tree56c40b1a7184d0bf786d8ceb49aefe548720ebf0
parentca12e1c91e561fa30465a37bc285bc52cbf04ed2 (diff)
add files benchmark
-rwxr-xr-xtests/runner.py45
1 files changed, 44 insertions, 1 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 0dde33c0..9f561473 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -5807,7 +5807,7 @@ elif 'benchmark' in str(sys.argv):
Building.COMPILER_TEST_OPTS = []
TEST_REPS = 10
- TOTAL_TESTS = 8
+ TOTAL_TESTS = 9
tests_done = 0
total_times = map(lambda x: 0., range(TOTAL_TESTS))
@@ -5940,6 +5940,49 @@ elif 'benchmark' in str(sys.argv):
'''
self.do_benchmark(src, [], 'final: 720.')
+ def test_files(self):
+ src = r'''
+ #include<stdio.h>
+ #include<stdlib.h>
+ #include<assert.h>
+ #include <unistd.h>
+
+ int main() {
+ int N = 100;
+ int M = 1000;
+ int K = 1000;
+ unsigned char *k = (unsigned char*)malloc(K+1), *k2 = (unsigned char*)malloc(K+1);
+ for (int i = 0; i < K; i++) {
+ k[i] = (i % 250) + 1;
+ }
+ k[K] = 0;
+ char buf[100];
+ for (int i = 0; i < N; i++) {
+ sprintf(buf, "/dev/shm/file-%d.dat", i);
+ FILE *f = fopen(buf, "w");
+ for (int j = 0; j < M; j++) {
+ fwrite(k, 1, (j % K) + 1, f);
+ }
+ fclose(f);
+ }
+ for (int i = 0; i < N; i++) {
+ sprintf(buf, "/dev/shm/file-%d.dat", i);
+ FILE *f = fopen(buf, "r");
+ for (int j = 0; j < M; j++) {
+ fread(k2, 1, (j % K) + 1, f);
+ }
+ fclose(f);
+ for (int j = 0; j < K; j++) {
+ assert(k[j] == k2[j]);
+ }
+ unlink(buf);
+ }
+ printf("ok");
+ return 1;
+ }
+ '''
+ self.do_benchmark(src, [], 'ok')
+
def test_copy(self):
src = r'''
#include<stdio.h>