V Forum

[ log in ]

Multi-language compiler benchmark

nordlow Jun 19 23:24
My project

https://github.com/nordlow/compiler-benchmark

benchmark the semantic and full object compilation phases of different compilers by analyzing a generated sample source. This source file is populated with a set of functions that are called from the main function. For this particular code casethe V compiler is abo
ut 60 times slower than the D compiler. Can you explain why is this case? I thought V would outperform D here.

To understand how the sample code is generated run

./benchmark --function-count 3 --function-depth 2

and check the output in the directory generated.

In the V case generated/v/linear.v will after this call contain

fn add_i64_
n0_h0(x i64) i64 { return x + 0 }
fn add_i64_n0(x i64) i64 { return x + add_i64_n0_h0(x) + 0 }

fn add_i64_n1_h0(x i64) i64 { return x + 1 }
fn add_i64_n1(x i64) i64 { return x + add_i64_n1_h0(x) + 1 }

fn add_i64_n2_h0(x i64) i64 { return x + 2 }
fn add_i64_n2(x i64) i64 { return x + add_i64_
nordlow Jun 20 12:39
Source example was truncated in initial post.

Here's the full version:

fn add_i64_n0_h0(x i64) i64 { return x + 0 }
fn add_i64_n0(x i64) i64 { return x + add_i64_n0_h0(x) + 0 }

fn add_i64_n1_h0(x i64) i64 { return x + 1 }
fn add_i64_n1(x i64) i64 { return x + add_i64_n1_h0(x) + 1 }

f
n add_i64_n2_h0(x i64) i64 { return x + 2 }
fn add_i64_n2(x i64) i64 { return x + add_i64_n2_h0(x) + 2 }

fn main() {
mut i64_sum := i64(0)
i64_sum += add_i64_n0(0)
i64_sum += add_i64_n1(1)
i64_sum += add_i64_n2(2)
exit(int(i64_sum))
}



Powered by Vorum, open-source blogging/forum software written in V