Greymeister.net

Sometimes C-ing Is Believing

I sometimes forget how fast C is. Until I am working on a problem with reading thousands of numbers from one file, sorting them, and writing the results into another file.

1
2
$ time groovy PartialPhoneFileSort.groovy 0 250000  
groovy PartialPhoneFileSort.groovy 0 250000  15.88s user 5.67s system 123% cpu 17.413 total
1
2
$ time ./a.out phonelist.dat sorted.dat 0 250000
./a.out phonelist.dat sorted.dat 0 250000  0.13s user 0.01s system 99% cpu 0.141 total

ToucheĀ“ sir. ToucheĀ“. But then again…

1
2
3
4
5
$ wc -l < PartialPhoneFileSort.groovy 
    29
    
$ wc -l < phonefilesort.c 
    74