Cesare Bavazzano <
cesare.b...@gmail.com> wrote:
> Hello Nemethi,
> No, I didn't make use of the -sortcommand option.
How _did_ you perform the sort then?
> Meanwhile I could try my application on a faster PC (2.80GHz, 16GB
> RAM) and it took just one second or two to sort the whole table.
> Possibly the solution for slowness is a new hardware rather than
> tuning your (fantastic) widget.
Except that even an "AMD Opteron Processor 2378 2.40 GHz; 4.00 GB RAM"
should sort 10,000 items much faster than 8 seconds.
Note:
$ cat /proc/cpuinfo
processor : 0
vendor_id : GenuineIntel
cpu family : 15
model : 2
model name : Intel(R) Celeron(R) CPU 2.00GHz
stepping : 7
cpu MHz : 1992.058
cache size : 128 KB
fdiv_bug : no
hlt_bug : no
f00f_bug : no
coma_bug : no
fpu : yes
fpu_exception : yes
cpuid level : 2
wp : yes
flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr
pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm
pbe up
pebs bts
bogomips : 3984.11
clflush size : 64
cache_alignment : 128
address sizes : 36 bits physical, 32 bits virtual
power management:
This is a Pentium4 Celeron running at 2Ghz - i.e., it is anchient
compared to your 'slower' operating CPU.
$ cat sort-test
#!/usr/bin/tclsh
for {set i 0} {$i < 10000} {incr i} {
set temp [list]
for {set j 0} {$j < 7} {incr j} {
lappend temp [expr {rand()}]
}
lappend data $temp
}
# temp is now a list of 10,000 elements, each element being a list of 7
# random values from rand()
# now, sort temp:
puts "-ascii [time {lsort -ascii -index 1 $data}]"
puts "-dictionary [time {lsort -dictionary -index 1 $data}]"
puts "-real [time {lsort -real -index 1 $data}]"
puts "-ascii [time {lsort -ascii -index 1 $data}]"
puts "-dictionary [time {lsort -dictionary -index 1 $data}]"
puts "-real [time {lsort -real -index 1 $data}]"
The above generates a 'random' set of data, then times sorting it,
twice to check for any 'warmup' effects.
Results:
$ ./sort-test
-ascii 558799 microseconds per iteration
-dictionary 50199 microseconds per iteration
-real 12513 microseconds per iteration
-ascii 21358 microseconds per iteration
-dictionary 52076 microseconds per iteration
-real 13300 microseconds per iteration
Note, the slowest, on a Pentium4 Celeron 2Ghz is .558 seconds (one half
second). On the second pass, the slowest time is .052 seconds (five
one hundreths of a second).
Taking eight seconds on your significantly faster CPU means something
else is wrong somewhere.