{"size": 742, "ext": "scrbl", "max_stars_repo_path": "post/2021-12-03-monotonic.scrbl", "max_stars_repo_name": "dannypsnl/racket-tw.github.io", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "post/2021-12-03-monotonic.scrbl", "max_issues_repo_name": "dannypsnl/racket-tw.github.io", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "post/2021-12-03-monotonic.scrbl", "max_forks_repo_name": "dannypsnl/racket-tw.github.io", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 49.4666666667, "max_line_length": 294, "alphanum_fraction": 0.7601078167}
#lang scribble/manual
@(require (for-label racket
                     monotonic))

@title{How to measure more percisely than milliseconds}
@author[(author+email "Lîm Tsú-thuàn" "dannypsnl@gmail.com")]

A common problem in Racket is that we can use @code{time} function to measure a codeblock's spend time, but it only provides milliseconds, what if we want more percise result? Library @code{monotonic} stands for this problem, by using @code{(current-monotonic-nanoseconds)}, we get nanoseconds.

@codeblock{
raco pkg install monotonic
}

And we can get microseconds by @code{current-inexact-milliseconds}, it will return value like @code{1289513737015.418}, where @code{1289513737015} is in milliseconds and @code{418} is in microseconds.
