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

Two Methods

There are two ways of constructing a software design: One way is to make it so simple that there are obviously no deficiencies, and the other way is to make it so complicated that there are no obvious deficiencies. The first method is far more difficult.

I think I know of a culprit for the latter case.