Skip to content

Commit 77bd3e8

Browse files
committed
Fix tests not passing for vim
Vim introduced more accurate profiling accuracy in commit 076de79ad832558267b3ff903c048df2f4c1a5d6 [0], which increases the precision down to nanosecond precision. However this collides with printf("%f") accuracy, which starts rounding floating point numbers much earlier. Since we compare the evaluated string with the real value retrieved from the benchmarking log file, we get an error if they don't match perfectly. Arguably that comparison is a bit too strict anyway, but luckily we can just set the precision for printf() by adding a ".x" prefix. This makes the tests pass again. [0] vim/vim#12129
1 parent 20c5b1c commit 77bd3e8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/test_general.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ func Test_performance()
145145
call assert_equal(printf("Called %d times", call_num), log[2])
146146

147147
let total_time = str2float(log[3]->matchstr('\d\.\d\+'))
148-
call assert_equal(printf("Total time: %f", total_time), log[3])
148+
call assert_equal(printf("Total time: %.9f", total_time), log[3])
149149

150150
let self_time = str2float(log[4]->matchstr('\d\.\d\+'))
151-
call assert_equal(printf(" Self time: %f", self_time), log[4])
151+
call assert_equal(printf(" Self time: %.9f", self_time), log[4])
152152

153153
let individual_time = total_time / call_num
154154
echo printf("Called %d times\nTotal time: %f\n Self time: %f\nIndividual time: %f", call_num, total_time, self_time, individual_time)

0 commit comments

Comments
 (0)