From b232f63df237f37edf9a611c8ca35f502314e702 Mon Sep 17 00:00:00 2001 From: Christien Rioux Date: Sat, 12 Dec 2015 01:21:25 -0800 Subject: [PATCH] add testfile scripts --- compare_testfiles.sh | 41 +++++++++++++++++++++++++++++++++++++++++ create_testfiles.sh | 8 ++++---- 2 files changed, 45 insertions(+), 4 deletions(-) create mode 100755 compare_testfiles.sh diff --git a/compare_testfiles.sh b/compare_testfiles.sh new file mode 100755 index 0000000..431136c --- /dev/null +++ b/compare_testfiles.sh @@ -0,0 +1,41 @@ +#!/bin/sh + + +lctest() +{ + OUT=`(time ./lc $1) 2>&1 | grep real | cut -f 2 | cut -c 3-` + echo "lc: $1 $OUT" + return 0 +} + +wctest() +{ + OUT=`(time wc -l $1) 2>&1 | grep real | cut -f 2 | cut -c 3-` + echo "wc: $1 $OUT" + return 0 +} + +pythontest() +{ + OUT=`(time echo "print str(sum(1 for line in open('$1'))) + ' $1'" | python) 2>&1 | grep real | cut -f 2 | cut -c 3-` + echo "python: $1 $OUT" + return 0 +} + +echo Timing for 'lc' +lctest test_10MB.txt +lctest test_100MB.txt +lctest test_1GB.txt +lctest test_10GB.txt + +echo Timing for 'python' +pythontest test_10MB.txt +pythontest test_100MB.txt +pythontest test_1GB.txt +pythontest test_10GB.txt + +echo Timing for 'wc' +wctest test_10MB.txt +wctest test_100MB.txt +wctest test_1GB.txt +wctest test_10GB.txt diff --git a/create_testfiles.sh b/create_testfiles.sh index 18a7539..9fb58a7 100755 --- a/create_testfiles.sh +++ b/create_testfiles.sh @@ -1,6 +1,6 @@ #!/bin/bash -scdd if=/dev/urandom of=test1.txt bs=1000000 count=10 -dd if=/dev/urandom of=test2.txt bs=1000000 count=100 -dd if=/dev/urandom of=test3.txt bs=1000000 count=1000 -cat test3.txt test3.txt test3.txt test3.txt test3.txt test3.txt test3.txt test3.txt test3.txt test3.txt > test4.txt +dd if=/dev/urandom of=test_10MB.txt bs=1000000 count=10 +dd if=/dev/urandom of=test_100MB.txt bs=1000000 count=100 +dd if=/dev/urandom of=test_1GB.txt bs=1000000 count=1000 +cat test_1GB.txt test_1GB.txt test_1GB.txt test_1GB.txt test_1GB.txt test_1GB.txt test_1GB.txt test_1GB.txt test_1GB.txt test_1GB.txt > test_10GB.txt