Stopwatch: measure function execution time
See original GitHub issueI discussed this idea with @gusty once on the fssf Slack, but just wanted to know if this could be relevant for the scope of FSharpPlus.
Lss,
[<RequireQualifiedAccess>]
module Stopwatch
open System.Diagnostics
let measure f =
let stopwatch = Stopwatch.StartNew()
let r = f()
stopwatch.Stop()
(r, stopwatch.Elapsed)
It’s a simple helper, so not sure it is worthwhile to add it to the library
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
c# - Calculate the execution time of a method
The Stopwatch measures elapsed time by counting timer ticks in the underlying timer mechanism. If the installed hardware and operating system ...
Read more >How to calculate the code execution time in C#?
C# includes the Stopwatch class in the System.Diagnostics namespace, which can be used to accurately measure the time taken for code execution.
Read more >How to measure the execution time of a C# code?
Method 1: Using the Stopwatch Class. One of the most straightforward ways to measure execution time in C# is to use the Stopwatch...
Read more >Measure execution time in C# | Techie Delight
Stopwatch GetTimestamp() method returns the current number of ticks of the underlying timer mechanism. 10,000 Ticks form a millisecond. ... That's all about ......
Read more >How to Calculate the Code Execution Time in C#? - ...
We can calculate the execution time of the code using StartNew() and Stop() methods. StartNew() method comes under the Stopwatch class and ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I was not aware of this class, but have made similar functions just using current time. I think it seems good.
The only other Stopwatch functionality amounts to being able to inspect seemingly constant IsHighResolution and Frequency (why are they instance fields then?) and to be able to continue timers.
I feel like these aren’t generally useful, and the
measure
function is what you’d normally want.something like
FSharpPlus.Scripting
sounds good?