You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We all know that there are many ways to build a v compiler. What's the difference? Which is better? So I tried to do some simple comparisons and tests.
v doctor
V full version: V 0.3.4 34163ae
OS: windows, Microsoft Windows 10 רҵ v19045 64 λ
Processor: 4 cpus, 64bit, little endian,
getwd: D:\v
vexe: D:\v\v.exe
vexe mtime: 2023-06-15 18:57:44
vroot: OK, value: D:\v
VMODULES: OK, value: C:\Users\TZ\.vmodules
VTMP: OK, value: C:\Users\TZ\AppData\Local\Temp\v_0
Git version: git version 2.36.0.windows.1
Git vroot status: weekly.2023.24-8-g34163ae4 (12 commit(s) behind V master)
.git/config present: true
CC version: Error: exec failed (CreateProcess) with code 2: 系统找不到指定的文件。
cmd: cc --version
thirdparty/tcc status: thirdparty-windows-amd64 e90c2620
result
command
v.exe size
benchmark(quintic average)
make -tcc
9464Kb
1711.1916ms
make -gcc
6831Kb
1732.874ms
make -clang
compile error
-
v self
9429Kb
1677.5034ms
v self -prod
3706Kb
1695.5788ms
benchmark code
module main
import rand
import benchmark
struct Person {
id int
name string
age int
mut:
group string
}
fn main() {
mut b := benchmark.start()
mut arr := []Person{}
num := 1000000 //百万
for i in 0 .. num {
p := Person{
id: rand.int_in_range(1, num) or { 1 }
name: 'tom${i}'
age: i % 150
group: ''
}
arr << p
}
for index, mut item in arr {
if index % 2 == 0 {
item.group = 'A'
} else {
item.group = 'B'
}
}
arr.sort_with_compare(fn (a &Person, b &Person) int {
if a.id < b.id {
return -1
}
if a.id > b.id {
return 1
}
return 0
})
// println('总数=${arr.len}')
// println('后10=${arr[arr.len - 10..]}')
b.measure('stop')
}
Conclusion
As you can see, the biggest difference is only the speed and size of v.exe generation, although the performance is also different but not obvious, so make-tcc or-gcc is the best choice, and the speed of generating v.exe is very fast. Of course, this is just a simple and not very rigorous test, welcome to continue research and discussion.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We all know that there are many ways to build a v compiler. What's the difference? Which is better? So I tried to do some simple comparisons and tests.
v doctor
result
benchmark code
Conclusion
As you can see, the biggest difference is only the speed and size of v.exe generation, although the performance is also different but not obvious, so make-tcc or-gcc is the best choice, and the speed of generating v.exe is very fast. Of course, this is just a simple and not very rigorous test, welcome to continue research and discussion.
Beta Was this translation helpful? Give feedback.
All reactions