Skip to content

@time macro can have huge error #39760

@ufechner7

Description

@ufechner7

Steps to reproduce:

mkdir temp
cd temp
git clone https://github.com/ufechner7/KiteViewer.git
cd KiteViewer
julia --project
using Pkg
Pkg.instantiate()
exit()
./create_sys_image.sh

And then execute the test:

./runjulia
include("test/time_bug.jl")

Result:

# [ Info:  started timer at: 2021-02-20T13:58:23.814
#   0.668130 seconds (933.81 k allocations: 55.527 MiB, 1.70% gc time, 98.76% compilation time)
# [ Info:          2.896614005s: 2 seconds, 896 milliseconds

# julia> 2.8966/0.668
# 4.336227544910179

# @time reports 0.67 seconds, while the real execution time incl. compilation is more like 2.90 seconds

This means that the @time macro reports a time that is more than a factor of four lower then the real execution time.

The same problem happens without using a custom sysimage, but the relative error is smaller (8s vs 5s).
This are times that I can measure with my stopwatch, so I can confirm that the time reported by
tick and tock is much closer to the real time than the time reported by the @time macro.

I would consider any error of more then 10% as a bug, in particular if the measured time is above 1s.

Any comment?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions