How fast is Argentum?

Argentum is advertised as fast. But how fast it actually is?

Here is a simple benchmark of three languages: Python, C, and an x86-64 assembly.

Though this benchmark is questionable:

  • not the best assembly implementation (push/pop etc),
  • magic numbers instead of bool values in Python,
  • absence of -O3 or other optimization parameters in C-compiler invocation,
  • not a C++ code.

This though gives a glimpse on how these languages are ordered in the axis of readability/speed: Python is x10 slower than C and Asm, which are about in par.

The code

I added here the Argentum example:

using utils { existsInRange, forRange }
using string;

fn isPrime(n int) bool {
    !existsInRange(2, n/2 + 1) `i
        n % i == 0

c = 0;
forRange(2, 250001) `i
    isPrime(i) ? c += 1;
sys_log("Number of primes is {c}")

I didn't try to do hacks:

  • isPrime is not inlined like in assembly case,
  • and it returns bool instead of int,
  • and it uses easy to support *range functions with lambdas instead of low level loops.

This Argentum code is easier to understand even than compared to Python: function isPrime defined as "not exists in range between a and b such i that n modulo i is 0. It's the exact math notation.

And the main program just counts all primes in the range and prints it out.

The speed

I believe this code wins in matters of readability. Let's look how it compared in terms of efficiency:

C++ compiled with default optimizations:

time ./cpp_O2
real    0m3.535s
user    0m3.535s
sys     0m0.000s


time ./ag
Number of primes is 22044
real    0m3.330s
user    0m3.330s
sys     0m0.000s

C++ with maximum optimizations:

time ./cpp_opt
real    0m2.891s
user    0m2.891s
sys     0m0.000s

I performed multiple cycles and took the best results.

The Conclusions

  • This benchmark tests very little: function/lambda calls, basic integer math, control structures.
  • In this small subset Argentum goes in par with typical C++ code and 12% slower than maximally-optimized C-code (these optimizations sometimes incompatible with production code, for example 40% if Debian packages break on O3 optimizations).
  • Right now Argentum compiler does not perform any optimizations on de-virtualization, inline and lowering of optional values. This is a huge field for improvements.
  • It needs more benchmarks - handling of data structures, multithreaded operations etc.


Argentum is in the same league of the fast languages as C/C++ though having ways to grow.

Leave a Reply

Your email address will not be published. Required fields are marked *