Skip to content

Instantly share code, notes, and snippets.

@olegchir
Last active December 4, 2021 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olegchir/43f6d6983e6bd44bdeb1478668f53a45 to your computer and use it in GitHub Desktop.
Save olegchir/43f6d6983e6bd44bdeb1478668f53a45 to your computer and use it in GitHub Desktop.

Purpose

I want to check claims that V is very slow, by comparing it with Golang: https://christine.website/blog/v-vaporware-2019-06-23

Assumptions

The test from the source article uses 1.2 million lines. V can't compile this number of lines. Go used 25G RAM on my machine, and was compiling it ~30 mins before I interrupted this hopless process. Therefore I slightly modified the test: we'll compile only 49k lines of code.

Generator

print "package main"
print "import \"fmt\""
print "func main() {"


for i = 0, 49000, 1
do
  print "fmt.Println(\"hello world\")"
end

print "}"

Generating source files

olegchir@OVERWATCH MINGW64 /c/temp
$ "C:\opt\lua-5.4.2_Win64_bin\lua54.exe" -v ./gen.lua > hello-world.go

Measuring results

First of all, run Golang on a file with an error to find the startup/warmup time

olegchir@OVERWATCH MINGW64 /c/temp
$ time "C:\Program Files\Go\bin\go.exe" build hello-world.go
hello-world.go:1:1: expected 'package', found Lua

real    0m1.075s
user    0m0.000s
sys     0m0.015s

One second warmup. Good. Now let's fix the source and compile.

time "C:\Program Files\Go\bin\go.exe" build hello-world-2.go

real    0m0.441s
user    0m0.015s
sys     0m0.000s

And this is the results for V compiler:

time "C:\opt\v_windows\v\v.exe" hello-world-3.v

real    0m1.497s
user    0m0.000s
sys     0m0.015s

Conclusion

V is 3 times slower than Go. But Go is a production-ready compiler, written by the whole world, including paid full-time Google developers. I think, V results are pretty impressive here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment