mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser/scanner: replace p.peek_tok2/3 with p.peek_token(2/3) (#8946)
This commit is contained in:
@@ -33,13 +33,18 @@ pub fn timing_measure(label string) {
|
||||
get_timers().show(label)
|
||||
}
|
||||
|
||||
pub fn timing_measure_cumulative(label string) {
|
||||
get_timers().measure_cumulative(label)
|
||||
}
|
||||
|
||||
pub fn timing_set_should_print(should_print bool) {
|
||||
mut t := util.timers
|
||||
t.should_print = should_print
|
||||
}
|
||||
|
||||
pub fn (mut t Timers) start(name string) {
|
||||
sw := time.new_stopwatch({})
|
||||
mut sw := t.swatches[name] or { time.new_stopwatch({}) }
|
||||
sw.start()
|
||||
t.swatches[name] = sw
|
||||
}
|
||||
|
||||
@@ -54,6 +59,35 @@ pub fn (mut t Timers) measure(name string) i64 {
|
||||
return ms
|
||||
}
|
||||
|
||||
pub fn (mut t Timers) measure_cumulative(name string) i64 {
|
||||
ms := t.measure(name)
|
||||
if name !in t.swatches {
|
||||
return ms
|
||||
}
|
||||
mut sw := t.swatches[name]
|
||||
sw.pause()
|
||||
t.swatches[name] = sw
|
||||
return ms
|
||||
}
|
||||
|
||||
pub fn (mut t Timers) measure_pause(name string) {
|
||||
if name !in t.swatches {
|
||||
return
|
||||
}
|
||||
mut sw := t.swatches[name]
|
||||
sw.pause()
|
||||
t.swatches[name] = sw
|
||||
}
|
||||
|
||||
pub fn (mut t Timers) measure_resume(name string) {
|
||||
if name !in t.swatches {
|
||||
return
|
||||
}
|
||||
mut sw := t.swatches[name]
|
||||
sw.start()
|
||||
t.swatches[name] = sw
|
||||
}
|
||||
|
||||
pub fn (mut t Timers) message(name string) string {
|
||||
ms := f64(t.measure(name)) / 1000.0
|
||||
value := bold('${ms:-8.3f}')
|
||||
@@ -68,6 +102,13 @@ pub fn (mut t Timers) show(label string) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn (mut t Timers) show_if_exists(label string) {
|
||||
if label !in t.swatches {
|
||||
return
|
||||
}
|
||||
t.show(label)
|
||||
}
|
||||
|
||||
pub fn (mut t Timers) dump_all() {
|
||||
for k, _ in t.swatches {
|
||||
elapsed := t.message(k)
|
||||
|
||||
Reference in New Issue
Block a user