Benchmarks Against AMX Mod X

After all this talk about optimizing SourceMod, has it paid off? Today I’ve updated our old AMX Mod X benchmark tests for SourceMod and added a few new tests.

The old test suite is available here.
Updated files for SourceMod support are here.

First, let’s show a pretty graph of the results (click to enlarge):

To keep things short, here’s a quick rundown of what’s faster and why:

  • Integer – We’ll chalk this one up to the opcode improvements of the JIT. Especially integer division got a big improvement, although this test covers the main four functions and modulus.
  • Float – The opcodes generated for float rounding got entirely redone by faluco and ended up much faster.
  • Format() – These are almost identical because SourceMod and AMX Mod X both have the same underlying code for formatting (“atcprintf”).
  • String Fetch – This is designed to test MF_GetAmxString/get_amxstring versus SourceMod’s IPluginContext::LocalToString by using str_to_num and StringToInt. SourceMod’s is obviously faster because there is no cell * to char * copying taking place, as there is with AMX Mod X.
  • Translation – SourceMod has a more efficient translation lookup cache, which uses a trie instead of a hash table.
  • Replace() – SourceMod’s ReplaceStringEx() is probably actually slower than AMX Mod X’s replace(). However, AMX Mod X doesn’t have a native implementation for replacing all occurrences, and SourceMod does. SourceMod’s single-replace function accounts for more cases internally so it can do replacements on buffers which are not long enough.

So, SourceMod is indeed marginally faster or more than AMX Mod X for most of the fundamental operations, which are integer and float math, and string fetching/translation.

One Response to “Benchmarks Against AMX Mod X”

  1. DeaD_EyE says:

    Nice work.

Leave a Reply

You must be logged in to post a comment.