| 1 | Running C and Haskell implemenations, each three times, |
|---|
| 2 | on strings of length 10, 50 and 100, using following command: |
|---|
| 3 | TIMEFORMAT=%3R;for l in " 10" " 50" 100; do for f in c h; do echo -n "$f $l "; (for i in 1 2 3; do time ./Hash $f $l >/dev/null; done;) 2>&1 | tr "\n" " ";echo; done; done |
|---|
| 4 | |
|---|
| 5 | c 10 0.348 0.344 0.347 |
|---|
| 6 | h 10 0.696 0.686 0.685 |
|---|
| 7 | c 50 1.025 1.015 1.002 |
|---|
| 8 | h 50 2.481 2.500 2.501 |
|---|
| 9 | c 100 1.891 1.931 1.901 |
|---|
| 10 | h 100 4.853 4.871 4.839 |
|---|
| 11 | |
|---|
| 12 | The resulting ratios (median / median) are |
|---|
| 13 | |
|---|
| 14 | h/c 10 1.98 |
|---|
| 15 | h/c 50 2.46 |
|---|
| 16 | h/c 100 2.55 |
|---|
| 17 | |
|---|
| 18 | Assembly of C-hash code (objdump -d --no-show-raw-insn) Assembly of Haskell-hash code |
|---|
| 19 | 00000000 <_c_hash>: 00000144 <_Main_zdwa_info>: |
|---|
| 20 | 0: push %ebp 144: add $0x8,%edi |
|---|
| 21 | 1: mov %esp,%ebp 147: cmp 0x5c(%ebx),%edi |
|---|
| 22 | 3: push %ebx 14a: ja 172 <_Main_zdwa_info+0x2e> |
|---|
| 23 | 4: mov 0x8(%ebp),%ebx 14c: mov 0x4(%ebp),%eax |
|---|
| 24 | 7: mov 0xc(%ebp),%ecx 14f: cmp 0x8(%ebp),%eax |
|---|
| 25 | a: mov $0x0,%edx 152: je 181 <_Main_zdwa_info+0x3d> |
|---|
| 26 | f: test %ecx,%ecx 154: mov 0x0(%ebp),%eax |
|---|
| 27 | 11: je 23 <_c_hash+0x23> 157: shl $0x5,%eax |
|---|
| 28 | 13: mov %edx,%eax 15a: mov 0x0(%ebp),%ecx |
|---|
| 29 | 15: shl $0x5,%eax 15d: add %eax,%ecx |
|---|
| 30 | 18: add %edx,%eax 15f: mov 0x4(%ebp),%eax |
|---|
| 31 | 1a: movsbl (%ebx),%edx 162: movzbl (%eax),%eax |
|---|
| 32 | 1d: xor %eax,%edx 165: xor %ecx,%eax |
|---|
| 33 | 1f: inc %ebx 167: incl 0x4(%ebp) |
|---|
| 34 | 20: dec %ecx 16a: mov %eax,0x0(%ebp) |
|---|
| 35 | 21: jne 13 <_c_hash+0x13> 16d: add $0xfffffff8,%edi |
|---|
| 36 | 23: mov %edx,%eax 170: jmp 144 <_Main_zdwa_info> |
|---|
| 37 | 25: pop %ebx 172: movl $0x8,0x70(%ebx) |
|---|
| 38 | 26: pop %ebp 179: mov $0x4c,%esi |
|---|
| 39 | 27: ret 17e: jmp *-0x8(%ebx) |
|---|
| 40 | 181: movl $0x0,-0x4(%edi) |
|---|
| 41 | 188: mov 0x0(%ebp),%eax |
|---|
| 42 | 18b: mov %eax,(%edi) |
|---|
| 43 | 18d: lea -0x3(%edi),%esi |
|---|
| 44 | 190: add $0xc,%ebp |
|---|
| 45 | 193: jmp *0x0(%ebp) |
|---|
| 46 | 196: xchg %ax,%ax |
|---|