mirror of
https://github.com/crioux/turbo-linecount.git
synced 2024-10-27 17:24:01 +00:00
b9a65a1269
pass Python code via -c instead of feeding to STDIN; on my system (Ubuntu) the later just measures the time to feed the code, not the execution (resulting in 0.00s runtime being reported)
50 lines
844 B
Bash
Executable File
50 lines
844 B
Bash
Executable File
#!/bin/sh
|
|
|
|
export TIME='real\t %e'
|
|
|
|
if [ "$1" = "" ]; then
|
|
echo "specify path to tlc binary"
|
|
exit 1
|
|
else
|
|
TLC=$1
|
|
fi
|
|
|
|
tlctest()
|
|
{
|
|
OUT=`(time $TLC $1) 2>&1 | grep real | cut -f 2 | cut -c 3-`
|
|
echo "tlc: $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 python -c "print str(sum(1 for line in open('$1'))) + ' $1'") 2>&1 | grep real | cut -f 2 | cut -c 3-`
|
|
echo "python: $1 $OUT"
|
|
return 0
|
|
}
|
|
|
|
echo Timing for 'tlc'
|
|
tlctest test_10MB.txt
|
|
tlctest test_100MB.txt
|
|
tlctest test_1GB.txt
|
|
tlctest 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
|