{"action":"created","issue":{"url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3695","labels_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3695/labels{/name}","comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3695/comments","events_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3695/events","html_url":"https://github.com/D-Programming-Language/phobos/pull/3695","id":109735318,"number":3695,"title":"Add std.benchmark with benchmarking functions that use MonoTime and Duration","user":{"login":"jmdavis","id":579956,"avatar_url":"https://avatars.githubusercontent.com/u/579956?v=3","gravatar_id":"","url":"https://api.github.com/users/jmdavis","html_url":"https://github.com/jmdavis","followers_url":"https://api.github.com/users/jmdavis/followers","following_url":"https://api.github.com/users/jmdavis/following{/other_user}","gists_url":"https://api.github.com/users/jmdavis/gists{/gist_id}","starred_url":"https://api.github.com/users/jmdavis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmdavis/subscriptions","organizations_url":"https://api.github.com/users/jmdavis/orgs","repos_url":"https://api.github.com/users/jmdavis/repos","events_url":"https://api.github.com/users/jmdavis/events{/privacy}","received_events_url":"https://api.github.com/users/jmdavis/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-05T05:49:21Z","updated_at":"2015-10-13T20:12:26Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3695","html_url":"https://github.com/D-Programming-Language/phobos/pull/3695","diff_url":"https://github.com/D-Programming-Language/phobos/pull/3695.diff","patch_url":"https://github.com/D-Programming-Language/phobos/pull/3695.patch"},"body":"Okay. I've been working towards getting rid of `TickDuration` for a while now, since it's highly confusing (one, it conflates a timestamp of the monotonic clock and a duration of the monotonic clock, and two it means that we have two duration types). `MonoTime` was added so that we could use it and `Duration` instead of `TickDuration` and then remove `TickDuration`, but the one thing remaining that we have to get rid of in order to be able to get rid of `TickDuration` is the benchmarking functions in std.datetime. But of course, they need to be replaced with benchmarking functions which use `MonoTime` and `Duration` before we can get rid of them.\r\n\r\nUnfortunately, because this involves function return types, we can't simply use overloads or anything like that to fix the problem, and the replacement functions need to go into another module so that they don't conflict or force us to come up with worse names. std.benchmark seems like the obvious choice, especially since there was talk of moving them there when Andrei's rejected std.benchmark was reviewed, so this PR creates those functions and puts them in the new module, std.benchmark (which just holds those functions and nothing really new). The std.datetime benchmarking functions can then be deprecated after std.benchmark has been out for a release (so that code that uses the benchmarking functions can build with both master and the previous release, whereas that wouldn't be the case if we deprecated the old stuff at the same time we added the new stuff), and then we can finally deprecate `TickDuration` in the release after that.\r\n\r\nThere were four benchmarking items in std.datetime, and this only keeps two. [`StopWatch`](http://dlang.org/phobos/std_datetime.html#StopWatch) and [`benchmark`](http://dlang.org/phobos/std_datetime.html#benchmark) have been ported over to std.benchmark. However, [`measureTime`](http://dlang.org/phobos/std_datetime.html#measureTime) and [`comparingBenchmark`](http://dlang.org/phobos/std_datetime.html#comparingBenchmark) have not.\r\n\r\nI thought that we'd deprecated `measureTime` ages ago, but apparently not. It's trivially replaced with a scope statement, and its documentation even shows how. So, I see no reason to keep it - especially when any code using it is going to have to be updated after this PR anyway. And `comparingBenchmark` is just a wrapper around benchmark that only takes two functions and divides the results to give a ratio. I don't know how valuable that is (it doesn't seem all that useful to me), but it seems like an awful lot of code to keep for what amounts to a simple wrapper (particularly since it declares its own type to hold the results). It just doesn't seem like it adds any real value, it seems like it's pretty trivial for someone to write the wrapper themselves if they really want it. So, I left it out.\r\n\r\nBut `StopWatch` and `benchmark` have been ported over (which was surprisingly painful for `StopWatch` - mostly because `TickDuration` is incredibly confusing). So, I don't think that any real functionality has been lost. Their API in std.benchmark is pretty much the same as it was in std.datetime - just with `MonoTime` and `Duration` instead, and `MonoTime` doesn't even make it into the public API. I did consider adding alternate functions to `StopWatch` that exposed the ticks for the rare case when someone might want that level of precision but decided that it wasn't worth complicating the API and might encourage folks to use the ticks and and shoot themselves in the foot, since it's harder to get that right when you start having to worry about converting clock frequencies and whatnot. `Duration` should work just fine except in rare cases.\r\n\r\nThis PR _does_ create a new module, so maybe it should be brought up in the newsgroup or get more of a review than these functions normally would, but it's one function and one type added, both of which already exist in std.datetime - except they use `TickDuration` there. So, having a full-on module review for it seems like overkill."},"comment":{"url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/comments/147838650","html_url":"https://github.com/D-Programming-Language/phobos/pull/3695#issuecomment-147838650","issue_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3695","id":147838650,"user":{"login":"jmdavis","id":579956,"avatar_url":"https://avatars.githubusercontent.com/u/579956?v=3","gravatar_id":"","url":"https://api.github.com/users/jmdavis","html_url":"https://github.com/jmdavis","followers_url":"https://api.github.com/users/jmdavis/followers","following_url":"https://api.github.com/users/jmdavis/following{/other_user}","gists_url":"https://api.github.com/users/jmdavis/gists{/gist_id}","starred_url":"https://api.github.com/users/jmdavis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jmdavis/subscriptions","organizations_url":"https://api.github.com/users/jmdavis/orgs","repos_url":"https://api.github.com/users/jmdavis/repos","events_url":"https://api.github.com/users/jmdavis/events{/privacy}","received_events_url":"https://api.github.com/users/jmdavis/received_events","type":"User","site_admin":false},"created_at":"2015-10-13T20:12:26Z","updated_at":"2015-10-13T20:12:26Z","body":"@andralex Would you please confirm whether you really want this in std.experimental or not? I'm guessing that you just glanced over this PR, saw that it was adding a new module into std, and told me to put it into std.experimental without really looking at what the PR contained, since while std.experimental makes sense in general for new modules, I don't see how it makes sense in this case. It's just moving existing functionality with a few updates to elsewhere in Phobos, not doing a major redesign or adding new functionality. If the code in question were being moved to an existing module rather than being put in a new one, the idea of putting it in std.experimental would never have even come up."}}