-
Notifications
You must be signed in to change notification settings - Fork 96
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stopwatch: measure function execution time #470
Comments
I am not sure, I have the feeling if there are other functions like this we can definitely add them. |
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 |
Thanks, in terms of module and namespaces, what do you think it would be the best option for this and possible other related functions? |
The idea kinda stemmed from Matlab [<AbstractClass; Sealed>]
type private TicToc private () =
static let Stopwatch = Stopwatch()
static member Tic = Stopwatch.Restart
static member Toc = Stopwatch.Elapsed
let tic = TicToc.Tic
let toc() = TicToc.Toc This is a simplified version which doesn't support nested scope (unlike Matlab), an alternative impl. could be. [<AbstractClass; Sealed>]
type private TicToc private () =
static let Stopwatches = Queue<Stopwatch>()
static member Tic = Stopwatch.StartNew >> Stopwatches.Value.Enqueue
static member Toc = Stopwatches.Dequeue().Elapsed
let tic() = TicToc.Tic()
let toc() = TicToc.Toc |
Seems like a nice thing to have. I can see how this small utility method could fit in with scripting. |
Agreed, in a scripting context, this can really come in handy to have shorthands like that. Actually I'm wondering if there should be a scripting namespace 🤔 |
something like |
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,
It's a simple helper, so not sure it is worthwhile to add it to the library
The text was updated successfully, but these errors were encountered: