question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stopwatch: measure function execution time

See original GitHub issue

I 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:open
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
adzcommented, Oct 19, 2021

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 measurefunction is what you’d normally want.

0reactions
cannorincommented, Oct 23, 2021

something like FSharpPlus.Scripting sounds good?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found