parent
837cada30c
commit
7664964c56
|
@ -30,7 +30,8 @@ fn main() {
|
||||||
checksum = 0
|
checksum = 0
|
||||||
for len in str_lens {
|
for len in str_lens {
|
||||||
end_pos := start_pos + len
|
end_pos := start_pos + len
|
||||||
checksum ^= wyhash.wyhash_c(unsafe { byteptr(bytepile.data) + start_pos }, u64(len), 1)
|
checksum ^= wyhash.wyhash_c(unsafe { byteptr(bytepile.data) + start_pos }, u64(len),
|
||||||
|
1)
|
||||||
start_pos = end_pos
|
start_pos = end_pos
|
||||||
}
|
}
|
||||||
bhashing_1.measure('wyhash.wyhash_c | checksum: ${checksum:22}')
|
bhashing_1.measure('wyhash.wyhash_c | checksum: ${checksum:22}')
|
||||||
|
|
|
@ -59,8 +59,8 @@ fn report_undocumented_functions_in_file(opt Options, file string) {
|
||||||
lines := contents.split('\n')
|
lines := contents.split('\n')
|
||||||
mut info := []UndocumentedFN{}
|
mut info := []UndocumentedFN{}
|
||||||
for i, line in lines {
|
for i, line in lines {
|
||||||
if line.starts_with('pub fn') ||
|
if line.starts_with('pub fn') || (line.starts_with('fn ') && !(line.starts_with('fn C.')
|
||||||
(line.starts_with('fn ') && !(line.starts_with('fn C.') || line.starts_with('fn main'))) {
|
|| line.starts_with('fn main'))) {
|
||||||
// println('Match: $line')
|
// println('Match: $line')
|
||||||
if i > 0 && lines.len > 0 {
|
if i > 0 && lines.len > 0 {
|
||||||
mut line_above := lines[i - 1]
|
mut line_above := lines[i - 1]
|
||||||
|
@ -89,7 +89,11 @@ fn report_undocumented_functions_in_file(opt Options, file string) {
|
||||||
}
|
}
|
||||||
if info.len > 0 {
|
if info.len > 0 {
|
||||||
for undocumented_fn in info {
|
for undocumented_fn in info {
|
||||||
tags_str := if opt.collect_tags && undocumented_fn.tags.len > 0 { '$undocumented_fn.tags' } else { '' }
|
tags_str := if opt.collect_tags && undocumented_fn.tags.len > 0 {
|
||||||
|
'$undocumented_fn.tags'
|
||||||
|
} else {
|
||||||
|
''
|
||||||
|
}
|
||||||
if opt.deprecated {
|
if opt.deprecated {
|
||||||
println('$file:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
|
println('$file:$undocumented_fn.line:0:$undocumented_fn.signature $tags_str')
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -404,7 +404,9 @@ pub fn building_any_v_binaries_failed() bool {
|
||||||
os.chdir(parent_dir)
|
os.chdir(parent_dir)
|
||||||
mut failed := false
|
mut failed := false
|
||||||
v_build_commands := ['$vexe -o v_g -g cmd/v', '$vexe -o v_prod_g -prod -g cmd/v',
|
v_build_commands := ['$vexe -o v_g -g cmd/v', '$vexe -o v_prod_g -prod -g cmd/v',
|
||||||
'$vexe -o v_cg -cg cmd/v', '$vexe -o v_prod_cg -prod -cg cmd/v', '$vexe -o v_prod -prod cmd/v']
|
'$vexe -o v_cg -cg cmd/v', '$vexe -o v_prod_cg -prod -cg cmd/v',
|
||||||
|
'$vexe -o v_prod -prod cmd/v',
|
||||||
|
]
|
||||||
mut bmark := benchmark.new_benchmark()
|
mut bmark := benchmark.new_benchmark()
|
||||||
for cmd in v_build_commands {
|
for cmd in v_build_commands {
|
||||||
bmark.step()
|
bmark.step()
|
||||||
|
|
|
@ -154,8 +154,8 @@ pub mut:
|
||||||
pub fn add_common_tool_options(mut context VGitOptions, mut fp flag.FlagParser) []string {
|
pub fn add_common_tool_options(mut context VGitOptions, mut fp flag.FlagParser) []string {
|
||||||
tdir := os.temp_dir()
|
tdir := os.temp_dir()
|
||||||
context.workdir = os.real_path(fp.string('workdir', `w`, tdir, 'A writable base folder. Default: $tdir'))
|
context.workdir = os.real_path(fp.string('workdir', `w`, tdir, 'A writable base folder. Default: $tdir'))
|
||||||
context.v_repo_url = fp.string('vrepo', 0, remote_v_repo_url, 'The url of the V repository. You can clone it locally too. See also --vcrepo below.')
|
context.v_repo_url = fp.string('vrepo', 0, vgit.remote_v_repo_url, 'The url of the V repository. You can clone it locally too. See also --vcrepo below.')
|
||||||
context.vc_repo_url = fp.string('vcrepo', 0, remote_vc_repo_url, 'The url of the vc repository. You can clone it
|
context.vc_repo_url = fp.string('vcrepo', 0, vgit.remote_vc_repo_url, 'The url of the vc repository. You can clone it
|
||||||
${flag.space}beforehand, and then just give the local folder
|
${flag.space}beforehand, and then just give the local folder
|
||||||
${flag.space}path here. That will eliminate the network ops
|
${flag.space}path here. That will eliminate the network ops
|
||||||
${flag.space}done by this tool, which is useful, if you want
|
${flag.space}done by this tool, which is useful, if you want
|
||||||
|
|
|
@ -12,4 +12,3 @@ pub fn show_topic(topic string) {
|
||||||
}
|
}
|
||||||
println(content)
|
println(content)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,13 @@ import vgit
|
||||||
const (
|
const (
|
||||||
tool_version = '0.0.5'
|
tool_version = '0.0.5'
|
||||||
tool_description = " Compares V executable size and performance,
|
tool_description = " Compares V executable size and performance,
|
||||||
| between 2 commits from V\'s local git history.
|
| between 2 commits from V's local git history.
|
||||||
| When only one commit is given, it is compared to master.
|
| When only one commit is given, it is compared to master.
|
||||||
| ".strip_margin()
|
| ".strip_margin()
|
||||||
)
|
)
|
||||||
|
|
||||||
struct Context {
|
struct Context {
|
||||||
cwd string // current working folder
|
cwd string // current working folder
|
||||||
mut:
|
mut:
|
||||||
vgo vgit.VGitOptions
|
vgo vgit.VGitOptions
|
||||||
a string // the full path to the 'after' folder inside workdir
|
a string // the full path to the 'after' folder inside workdir
|
||||||
|
@ -20,7 +20,7 @@ mut:
|
||||||
vc string // the full path to the vc folder inside workdir. It is used during bootstrapping v from the C source.
|
vc string // the full path to the vc folder inside workdir. It is used during bootstrapping v from the C source.
|
||||||
commit_before string // the git commit for the 'before' state
|
commit_before string // the git commit for the 'before' state
|
||||||
commit_after string // the git commit for the 'after' state
|
commit_after string // the git commit for the 'after' state
|
||||||
warmups int // how many times to execute a command before gathering stats
|
warmups int // how many times to execute a command before gathering stats
|
||||||
hyperfineopts string // use for additional CLI options that will be given to the hyperfine command
|
hyperfineopts string // use for additional CLI options that will be given to the hyperfine command
|
||||||
vflags string // other v options to pass to compared v commands
|
vflags string // other v options to pass to compared v commands
|
||||||
}
|
}
|
||||||
|
@ -50,14 +50,23 @@ fn (c Context) compare_versions() {
|
||||||
// The first is the baseline, against which all the others will be compared.
|
// The first is the baseline, against which all the others will be compared.
|
||||||
// It is the fastest, since hello_world.v has only a single println in it,
|
// It is the fastest, since hello_world.v has only a single println in it,
|
||||||
mut perf_files := []string{}
|
mut perf_files := []string{}
|
||||||
perf_files <<
|
perf_files << c.compare_v_performance('source_hello', [
|
||||||
c.compare_v_performance('source_hello', ['vprod @DEBUG@ -o source.c examples/hello_world.v', 'vprod -o source.c examples/hello_world.v', 'v @DEBUG@ -o source.c examples/hello_world.v', 'v -o source.c examples/hello_world.v'])
|
'vprod @DEBUG@ -o source.c examples/hello_world.v',
|
||||||
perf_files <<
|
'vprod -o source.c examples/hello_world.v',
|
||||||
c.compare_v_performance('source_v', ['vprod @DEBUG@ -o source.c @COMPILER@', 'vprod -o source.c @COMPILER@', 'v @DEBUG@ -o source.c @COMPILER@', 'v -o source.c @COMPILER@'])
|
'v @DEBUG@ -o source.c examples/hello_world.v',
|
||||||
perf_files <<
|
'v -o source.c examples/hello_world.v',
|
||||||
c.compare_v_performance('binary_hello', ['vprod -o hello examples/hello_world.v', 'v -o hello examples/hello_world.v'])
|
])
|
||||||
perf_files <<
|
perf_files << c.compare_v_performance('source_v', ['vprod @DEBUG@ -o source.c @COMPILER@',
|
||||||
c.compare_v_performance('binary_v', ['vprod -o binary @COMPILER@', 'v -o binary @COMPILER@'])
|
'vprod -o source.c @COMPILER@', 'v @DEBUG@ -o source.c @COMPILER@',
|
||||||
|
'v -o source.c @COMPILER@',
|
||||||
|
])
|
||||||
|
perf_files << c.compare_v_performance('binary_hello', [
|
||||||
|
'vprod -o hello examples/hello_world.v',
|
||||||
|
'v -o hello examples/hello_world.v',
|
||||||
|
])
|
||||||
|
perf_files << c.compare_v_performance('binary_v', ['vprod -o binary @COMPILER@',
|
||||||
|
'v -o binary @COMPILER@',
|
||||||
|
])
|
||||||
println('All performance files:')
|
println('All performance files:')
|
||||||
for f in perf_files {
|
for f in perf_files {
|
||||||
println(' $f')
|
println(' $f')
|
||||||
|
@ -97,7 +106,9 @@ fn (c &Context) prepare_v(cdir string, commit string) {
|
||||||
scripting.run('upx -qqq --lzma vprod_stripped_upxed')
|
scripting.run('upx -qqq --lzma vprod_stripped_upxed')
|
||||||
scripting.show_sizes_of_files(['$cdir/cv', '$cdir/cv_stripped', '$cdir/cv_stripped_upxed'])
|
scripting.show_sizes_of_files(['$cdir/cv', '$cdir/cv_stripped', '$cdir/cv_stripped_upxed'])
|
||||||
scripting.show_sizes_of_files(['$cdir/v', '$cdir/v_stripped', '$cdir/v_stripped_upxed'])
|
scripting.show_sizes_of_files(['$cdir/v', '$cdir/v_stripped', '$cdir/v_stripped_upxed'])
|
||||||
scripting.show_sizes_of_files(['$cdir/vprod', '$cdir/vprod_stripped', '$cdir/vprod_stripped_upxed'])
|
scripting.show_sizes_of_files(['$cdir/vprod', '$cdir/vprod_stripped',
|
||||||
|
'$cdir/vprod_stripped_upxed',
|
||||||
|
])
|
||||||
vversion := scripting.run('$cdir/v -version')
|
vversion := scripting.run('$cdir/v -version')
|
||||||
vcommit := scripting.run('git rev-parse --short --verify HEAD')
|
vcommit := scripting.run('git rev-parse --short --verify HEAD')
|
||||||
println('V version is: $vversion , local source commit: $vcommit')
|
println('V version is: $vversion , local source commit: $vcommit')
|
||||||
|
@ -110,7 +121,8 @@ fn (c &Context) prepare_v(cdir string, commit string) {
|
||||||
scripting.run('wc cmd/v/*.v vlib/compiler/*.v | tail -n -1'))
|
scripting.run('wc cmd/v/*.v vlib/compiler/*.v | tail -n -1'))
|
||||||
}
|
}
|
||||||
} else if vgit_context.vvlocation == 'v.v' {
|
} else if vgit_context.vvlocation == 'v.v' {
|
||||||
println('Source lines of the compiler: ' + scripting.run('wc v.v vlib/compiler/*.v | tail -n -1'))
|
println('Source lines of the compiler: ' +
|
||||||
|
scripting.run('wc v.v vlib/compiler/*.v | tail -n -1'))
|
||||||
} else {
|
} else {
|
||||||
println('Source lines of the compiler: ' + scripting.run('wc compiler/*.v | tail -n -1'))
|
println('Source lines of the compiler: ' + scripting.run('wc compiler/*.v | tail -n -1'))
|
||||||
}
|
}
|
||||||
|
@ -140,17 +152,26 @@ fn (c Context) compare_v_performance(label string, commands []string) string {
|
||||||
println(cmd)
|
println(cmd)
|
||||||
}
|
}
|
||||||
for cmd in commands {
|
for cmd in commands {
|
||||||
hyperfine_commands_arguments <<
|
hyperfine_commands_arguments << " \'cd ${c.b:-34s} ; ./$cmd \' ".replace_each([
|
||||||
" \'cd ${c.b:-34s} ; ./$cmd \' ".replace_each(['@COMPILER@', source_location_b, '@DEBUG@', debug_option_b])
|
'@COMPILER@',
|
||||||
|
source_location_b,
|
||||||
|
'@DEBUG@',
|
||||||
|
debug_option_b,
|
||||||
|
])
|
||||||
}
|
}
|
||||||
for cmd in commands {
|
for cmd in commands {
|
||||||
hyperfine_commands_arguments <<
|
hyperfine_commands_arguments << " \'cd ${c.a:-34s} ; ./$cmd \' ".replace_each([
|
||||||
" \'cd ${c.a:-34s} ; ./$cmd \' ".replace_each(['@COMPILER@', source_location_a, '@DEBUG@', debug_option_a])
|
'@COMPILER@',
|
||||||
|
source_location_a,
|
||||||
|
'@DEBUG@',
|
||||||
|
debug_option_a,
|
||||||
|
])
|
||||||
}
|
}
|
||||||
// /////////////////////////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////////////////////////
|
||||||
cmd_stats_file := os.real_path([c.vgo.workdir, 'v_performance_stats_${label}.json'].join(os.path_separator))
|
cmd_stats_file := os.real_path([c.vgo.workdir, 'v_performance_stats_${label}.json'].join(os.path_separator))
|
||||||
comparison_cmd := 'hyperfine $c.hyperfineopts ' + '--export-json $cmd_stats_file ' + '--time-unit millisecond ' +
|
comparison_cmd := 'hyperfine $c.hyperfineopts ' + '--export-json $cmd_stats_file ' +
|
||||||
'--style full --warmup $c.warmups ' + hyperfine_commands_arguments.join(' ')
|
'--time-unit millisecond ' + '--style full --warmup $c.warmups ' +
|
||||||
|
hyperfine_commands_arguments.join(' ')
|
||||||
// /////////////////////////////////////////////////////////////////////////////
|
// /////////////////////////////////////////////////////////////////////////////
|
||||||
if c.vgo.verbose {
|
if c.vgo.verbose {
|
||||||
println(comparison_cmd)
|
println(comparison_cmd)
|
||||||
|
|
|
@ -364,15 +364,15 @@ fn (mut r Repl) get_one_line(prompt string) ?string {
|
||||||
|
|
||||||
fn cleanup_files(files []string) {
|
fn cleanup_files(files []string) {
|
||||||
for file in files {
|
for file in files {
|
||||||
os.rm(file) or { }
|
os.rm(file) or {}
|
||||||
$if windows {
|
$if windows {
|
||||||
os.rm(file[..file.len - 2] + '.exe') or { }
|
os.rm(file[..file.len - 2] + '.exe') or {}
|
||||||
$if msvc {
|
$if msvc {
|
||||||
os.rm(file[..file.len - 2] + '.ilk') or { }
|
os.rm(file[..file.len - 2] + '.ilk') or {}
|
||||||
os.rm(file[..file.len - 2] + '.pdb') or { }
|
os.rm(file[..file.len - 2] + '.pdb') or {}
|
||||||
}
|
}
|
||||||
} $else {
|
} $else {
|
||||||
os.rm(file[..file.len - 2]) or { }
|
os.rm(file[..file.len - 2]) or {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,9 +23,7 @@ const (
|
||||||
'vlib/gg/m4/matrix.v' /* has hand crafted meaningful formatting of matrices */,
|
'vlib/gg/m4/matrix.v' /* has hand crafted meaningful formatting of matrices */,
|
||||||
]
|
]
|
||||||
vfmt_verify_list = [
|
vfmt_verify_list = [
|
||||||
'cmd/v/v.v',
|
'cmd/',
|
||||||
'cmd/tools/vdoc/',
|
|
||||||
'cmd/tools/vvet/',
|
|
||||||
'vlib/arrays/',
|
'vlib/arrays/',
|
||||||
'vlib/benchmark/',
|
'vlib/benchmark/',
|
||||||
'vlib/bitfield/',
|
'vlib/bitfield/',
|
||||||
|
|
|
@ -7,19 +7,19 @@ import v.util
|
||||||
const (
|
const (
|
||||||
known_failing_exceptions = [
|
known_failing_exceptions = [
|
||||||
'vlib/crypto/aes/const.v',
|
'vlib/crypto/aes/const.v',
|
||||||
/* multiple narrow columns of []string turned to 1 long single column, otherwise works */
|
// multiple narrow columns of []string turned to 1 long single column, otherwise works
|
||||||
'vlib/v/gen/js/tests/life.v',
|
'vlib/v/gen/js/tests/life.v',
|
||||||
/* error: unexpected `,`, expecting ), on JS.setInterval(fn () { show(game) game = step(game) }, 500) */
|
// error: unexpected `,`, expecting ), on JS.setInterval(fn () { show(game) game = step(game) }, 500)
|
||||||
'vlib/builtin/js/builtin.v',
|
'vlib/builtin/js/builtin.v',
|
||||||
/* JS.console.error(s) => JS.error(s), JS.process.exit(c) => JS.exit(c) */
|
// JS.console.error(s) => JS.error(s), JS.process.exit(c) => JS.exit(c)
|
||||||
'vlib/builtin/js/jsfns_node.js.v',
|
'vlib/builtin/js/jsfns_node.js.v',
|
||||||
'vlib/builtin/js/jsfns.js.v',
|
'vlib/builtin/js/jsfns.js.v',
|
||||||
'vlib/builtin/js/jsfns_browser.js.v',
|
'vlib/builtin/js/jsfns_browser.js.v',
|
||||||
/* error: expr(): bad token `asm`, on `asm {}` */
|
// error: expr(): bad token `asm`, on `asm {}`
|
||||||
'vlib/builtin/bare/linuxsys_bare.v',
|
'vlib/builtin/bare/linuxsys_bare.v',
|
||||||
/* total chaos (duplicated code several times) in array_eq_test.v */
|
// total chaos (duplicated code several times) in array_eq_test.v
|
||||||
'vlib/builtin/array_eq_test.v',
|
'vlib/builtin/array_eq_test.v',
|
||||||
/* the fn args are removed, then `cb fn (picohttpparser.Request, mut picohttpparser.Response)` can not be reparsed */
|
// the fn args are removed, then `cb fn (picohttpparser.Request, mut picohttpparser.Response)` can not be reparsed
|
||||||
'vlib/picoev/picoev.v',
|
'vlib/picoev/picoev.v',
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -7,7 +7,7 @@ fn main() {
|
||||||
mut cm := vcache.new_cache_manager([])
|
mut cm := vcache.new_cache_manager([])
|
||||||
cpath := cm.basepath
|
cpath := cm.basepath
|
||||||
if os.exists(cpath) && os.is_dir(cpath) {
|
if os.exists(cpath) && os.is_dir(cpath) {
|
||||||
os.rmdir_all(cpath) or { }
|
os.rmdir_all(cpath) or {}
|
||||||
}
|
}
|
||||||
println('V cache folder $cpath was wiped.')
|
println('V cache folder $cpath was wiped.')
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,7 +19,7 @@ pub fn print_and_exit(topic string) {
|
||||||
exit(1)
|
exit(1)
|
||||||
}
|
}
|
||||||
// `init` has the same help topic as `new`
|
// `init` has the same help topic as `new`
|
||||||
name := if topic == "init" { "new" } else { topic }
|
name := if topic == 'init' { 'new' } else { topic }
|
||||||
target_topic := os.join_path(vroot, 'cmd', 'v', 'help', '${name}.txt')
|
target_topic := os.join_path(vroot, 'cmd', 'v', 'help', '${name}.txt')
|
||||||
content := os.read_file(target_topic) or {
|
content := os.read_file(target_topic) or {
|
||||||
eprintln(help.unknown_topic)
|
eprintln(help.unknown_topic)
|
||||||
|
|
Loading…
Reference in New Issue