[Mono-list] Mono/C# microbenchmarks

David Jeske jeske@chat.net
Mon, 19 Aug 2002 23:06:14 -0700

I finally have successfully built a semi-recent snapshot of the Mono
environment to run some microbenchmarks that make up a simple
scripting performance test suite and I figured someone might be
interseted. You can see some basic information about scriptperf here:


  (the results posted there don't include C#, but the code is there)

Overall, the performance of Mono/C# is pretty darn close to the C
version. This is great given that mono is still very much a work in
progress. The MS.NET runtime fairs slightly better, especially
considering it's on a slightly slower CPU.

I'm somewhat surprised at how much faster the hashtable based
index_test and index_string_test come out in the C version. There must
be some nasty stuff going on in C# to get a unique hash value, particularly
for integers.

Oddly, Python seems to be in the same ballpark as C# on the index_test
and index_string_test. That leads me to believe it's some kind of
type-munging overhead taking the time, which absent from the C/glib

[ linux tests are on a celeron 400, windows tests are on a P-II 300 ]

-- mono linux (C# version)

mozart:~/src/scriptperf> time mono scriptperf.exe
loop_test   500000 elapsed: 0.138
index_test   1000000 elapsed: 12.713
index_string_test   1000000 elapsed: 4.925
nested_int_test   23 elapsed: 0.113
nested_test   23 elapsed: 0.148
return_test   5000000 elapsed: 0.061
object_test   5000000 elapsed: 0.218
17.310u 0.750s 0:18.58 97.2%    0+0k 0+0io 767pf+0w

-- MS.NET Win2k (C# version)

loop_test   500000 elapsed: 0.09
index_test   1000000 elapsed: 7.911
index_string_test   1000000 elapsed: 1.472
nested_int_test   23 elapsed: 0.06
nested_test   23 elapsed: 0.06
return_test   5000000 elapsed: 0.05
object_test   5000000 elapsed: 0.13

-- gcc -O3 linux (C version)

mozart:~/src/scriptperf> gcc -O3 -o scriptperf_c -I/usr/include/glib-1.2 -I/usr/lib/glib/include -L/usr/lib -lglib scriptperf.c
mozart:~/src/scriptperf> time ./scriptperf_c
            fib_test (30) elapsed:  0.12 seconds
           loop_test (500000) elapsed:  0.04 seconds
          index_test (1000000) elapsed:  0.57 seconds
   index_string_test (1000000) elapsed:  1.11 seconds
     nested_int_test (23) elapsed:  0.04 seconds
          returntest (5000000) elapsed:  0.03 seconds
            functest (5000000) elapsed:  0.02 seconds
          objecttest (5000000) elapsed:  0.14 seconds
      file_line_test (1) elapsed:  1.74 seconds
file_line_split_test (1) elapsed:  2.43 seconds
    list_append_test (50000) elapsed:  0.01 seconds
  list_traverse_test (500000) elapsed:  0.15 seconds
6.010u 0.320s 0:06.40 98.9%     0+0k 0+0io 1231pf+0w

-- python1.5.2 linux (Python version)

mozart:~/src/scriptperf> time ./all_test.py
           loop_test(500000) elapsed: 9.54620301723 seconds
          index_test(1000000) elapsed: 5.96789705753 seconds
   index_string_test(1000000) elapsed: 4.21141695976 seconds
     nested_int_test(23) elapsed: 12.8061180115 seconds
          returntest(5000000) elapsed: 19.4322520494 seconds
            functest(5000000) elapsed: 18.1918109655 seconds
          objecttest(5000000) elapsed: 21.314817071 seconds
88.780u 1.830s 1:31.81 98.6%    0+0k 0+0io 262pf+0w

David Jeske (N9LCA) + http://www.chat.net/~jeske/ + jeske@chat.net