Skip to content

Instantly share code, notes, and snippets.

@olegchir
Last active December 4, 2021 02:43
Show Gist options
  • Save olegchir/43f6d6983e6bd44bdeb1478668f53a45 to your computer and use it in GitHub Desktop.
Save olegchir/43f6d6983e6bd44bdeb1478668f53a45 to your computer and use it in GitHub Desktop.

Revisions

  1. olegchir revised this gist Dec 4, 2021. 1 changed file with 27 additions and 5 deletions.
    32 changes: 27 additions & 5 deletions 1.2 million lines in Go.md
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,13 @@
    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

    ```lua
    @@ -11,7 +18,7 @@ print "import \"fmt\""
    print "func main() {"


    for i = 0, 1200000, 1
    for i = 0, 49000, 1
    do
    print "fmt.Println(\"hello world\")"
    end
    @@ -40,11 +47,26 @@ user 0m0.000s
    sys 0m0.015s
    ```

    One second warmup. Good. Now let's compile.
    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
    Well... it's running almost 5 minutes and still did not finished.
    Also, Golang consumed almost 25 Gb memory on my Windows box, it's half of my available RAM.
    real 0m1.497s
    user 0m0.000s
    sys 0m0.015s
    ```

    # Conclusion

    2 seconds for V (if it is really true) is a pretty impressive result. It is not slow at all.
    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.
  2. olegchir renamed this gist Dec 4, 2021. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion compiling 1M lines → 1.2 million lines in Go.md
    Original file line number Diff line number Diff line change
    @@ -43,4 +43,8 @@ sys 0m0.015s
    One second warmup. Good. Now let's compile.

    Well... it's running almost 5 minutes and still did not finished.
    Also, Golang consumed almost 25 Gb memory on my Windows box, it's half of my available RAM.
    Also, Golang consumed almost 25 Gb memory on my Windows box, it's half of my available RAM.

    # Conclusion

    2 seconds for V (if it is really true) is a pretty impressive result. It is not slow at all.
  3. olegchir created this gist Dec 4, 2021.
    46 changes: 46 additions & 0 deletions compiling 1M lines
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,46 @@
    # 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>

    # Generator

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


    for i = 0, 1200000, 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 compile.

    Well... it's running almost 5 minutes and still did not finished.
    Also, Golang consumed almost 25 Gb memory on my Windows box, it's half of my available RAM.