1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

ci: workaround for v vet failing for v clean-code over the new v bench script (using \ in its path on windows).

This commit is contained in:
Delyan Angelov 2022-12-19 12:31:11 +02:00
parent 8873127687
commit 353fdb4ca0

View File

@ -16,55 +16,57 @@ import benchmark
// SPENT 319.897 ms in sum: 1000000 | key in a_as_middle // SPENT 319.897 ms in sum: 1000000 | key in a_as_middle
// SPENT 1.842 ms in sum: 1000000 | key in a_as_first // SPENT 1.842 ms in sum: 1000000 | key in a_as_first
max_iterations := os.getenv_opt('MAX_ITERATIONS') or { '1000' }.int() fn main() {
max_items := os.getenv_opt('MAX_ITEMS') or { '100' }.int() max_iterations := os.getenv_opt('MAX_ITERATIONS') or { '1000' }.int()
eprintln('> max_iterations: ${max_iterations} over max_items: ${max_items}') max_items := os.getenv_opt('MAX_ITEMS') or { '100' }.int()
key := 'abc' eprintln('> max_iterations: ${max_iterations} over max_items: ${max_items}')
mut sum := 0 key := 'abc'
mut m := map[string]bool{} mut sum := 0
m[key] = true mut m := map[string]bool{}
for _ in 0 .. max_items { m[key] = true
m[rand.string(20)] = true for _ in 0 .. max_items {
} m[rand.string(20)] = true
a_as_first := m.keys() }
a_as_last := m.keys().reverse() a_as_first := m.keys()
mut a_as_middle := a_as_first[1..a_as_first.len / 2] a_as_last := m.keys().reverse()
a_as_middle << key mut a_as_middle := a_as_first[1..a_as_first.len / 2]
a_as_middle << a_as_first[a_as_first.len / 2..] a_as_middle << key
eprintln('> m.len: ${m.len} | a_as_first.len: ${a_as_first.len} | a_as_last.len: ${a_as_last.len} | a_as_middle.len: ${a_as_middle.len}') a_as_middle << a_as_first[a_as_first.len / 2..]
eprintln('> m.len: ${m.len} | a_as_first.len: ${a_as_first.len} | a_as_last.len: ${a_as_last.len} | a_as_middle.len: ${a_as_middle.len}')
mut b := benchmark.start() mut b := benchmark.start()
// //
sum = 0 sum = 0
for _ in 0 .. max_iterations { for _ in 0 .. max_iterations {
sum += int(m[key]) sum += int(m[key])
} }
b.measure('sum: ${sum} | m[key]') b.measure('sum: ${sum} | m[key]')
sum = 0 sum = 0
for _ in 0 .. max_iterations { for _ in 0 .. max_iterations {
sum += int(key in m) sum += int(key in m)
} }
b.measure('sum: ${sum} | key in m') b.measure('sum: ${sum} | key in m')
// //
b = benchmark.start() b = benchmark.start()
// //
sum = 0 sum = 0
for _ in 0 .. max_iterations { for _ in 0 .. max_iterations {
sum += int(key in a_as_last) sum += int(key in a_as_last)
} }
b.measure('sum: ${sum} | key in a_as_last') b.measure('sum: ${sum} | key in a_as_last')
sum = 0 sum = 0
for _ in 0 .. max_iterations { for _ in 0 .. max_iterations {
sum += int(key in a_as_middle) sum += int(key in a_as_middle)
} }
b.measure('sum: ${sum} | key in a_as_middle') b.measure('sum: ${sum} | key in a_as_middle')
sum = 0 sum = 0
for _ in 0 .. max_iterations { for _ in 0 .. max_iterations {
sum += int(key in a_as_first) sum += int(key in a_as_first)
}
b.measure('sum: ${sum} | key in a_as_first')
} }
b.measure('sum: ${sum} | key in a_as_first')