criterion-measurement 0.1.2.0 → 0.1.3.0
raw patch · 7 files changed
+47/−20 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +1/−1
- cbits/cycles.c +10/−1
- cbits/time-osx.c +3/−12
- changelog.md +25/−0
- criterion-measurement.cabal +6/−4
- src/Criterion/Measurement.hs +1/−1
- src/Criterion/Measurement/Types.hs +1/−1
README.md view
@@ -1,5 +1,5 @@ # criterion-measurement -[](https://travis-ci.org/bos/criterion)+[](https://github.com/haskell/criterion/actions?query=workflow%3AHaskell-CI) Measurement-related functionality extracted from Criterion, with minimal dependencies. The rationale for this is to enable alternative analysis front-ends.
cbits/cycles.c view
@@ -1,6 +1,15 @@ #include "Rts.h" -#if x86_64_HOST_ARCH || i386_HOST_ARCH+#if darwin_HOST_OS++#include <mach/mach_time.h>++StgWord64 criterion_rdtsc(void)+{+ return mach_absolute_time();+}++#elif x86_64_HOST_ARCH || i386_HOST_ARCH StgWord64 criterion_rdtsc(void) {
cbits/time-osx.c view
@@ -1,20 +1,11 @@ #include <mach/mach.h>-#include <mach/mach_time.h>--static mach_timebase_info_data_t timebase_info;-static double timebase_recip;+#include <time.h> -void criterion_inittime(void)-{- if (timebase_recip == 0) {- mach_timebase_info(&timebase_info);- timebase_recip = (timebase_info.denom / timebase_info.numer) / 1e9;- }-}+void criterion_inittime(void) {} double criterion_gettime(void) {- return mach_absolute_time() * timebase_recip;+ return clock_gettime_nsec_np(CLOCK_UPTIME_RAW) / 1e9; } static double to_double(time_value_t time)
changelog.md view
@@ -1,3 +1,28 @@+0.1.3.0++* Change `criterion_rdtsc` to return `mach_absolute_time` on macOS. This is a+ portable way of returning the number of CPU cycles that works on both Intel-+ and ARM-based Macs.++* Change `criterion_gettime` to use `clock_gettime_nsec_np` instead of+ `mach_absolute_time` on macOS. While `mach_absolute_time` has nanosecond+ resolution on Intel-based Macs, this is not the case on ARM-based Macs, so+ the previous `mach_absolute_time`-based implementation would return incorrect+ timing results on Apple silicon.++ There are two minor consequences of this change:++ * `criterion-measurement` now only supports macOS 10.02 or later, as that is+ the first version to have `clock_gettime_nsec_np`. As macOS 10.02 was+ released in 2002, this is unlikely to affect users, but please speak up if+ this is a problem for you.++ * As `clock_gettime_nsec_np` does not require any special initialization+ code, `criterion_inittime` is now a no-op on macOS. If you manually invoke+ the `getTime` function in your code, however, it is still important that+ you `initializeTime` beforehand, as this is still required for the Windows+ implementation to work correctly.+ 0.1.2.0 * Ensure that `Criterion.Measurement.Types.Internal` is always compiled with
criterion-measurement.cabal view
@@ -1,8 +1,8 @@ name: criterion-measurement-version: 0.1.2.0+version: 0.1.3.0 synopsis: Criterion measurement functionality and associated types description: Measurement-related functionality extracted from Criterion, with minimal dependencies. The rationale for this is to enable alternative analysis front-ends.-homepage: https://github.com/bos/criterion+homepage: https://github.com/haskell/criterion license: BSD3 license-file: LICENSE author: Bryan O'Sullivan <bos@serpentine.com>@@ -21,7 +21,9 @@ GHC==8.2.2, GHC==8.4.4, GHC==8.6.5,- GHC==8.8.1+ GHC==8.8.4,+ GHC==8.10.4,+ GHC==9.0.1 flag fast description: compile without optimizations@@ -67,5 +69,5 @@ source-repository head type: git- location: https://github.com/bos/criterion+ location: https://github.com/haskell/criterion subdir: criterion-measurement
src/Criterion/Measurement.hs view
@@ -399,7 +399,7 @@ -- accomplishes). -- -- It is imperative that you call 'initializeTime' before calling 'getTime'.--- (See [this bug report](https://github.com/bos/criterion/issues/195) for an+-- (See [this bug report](https://github.com/haskell/criterion/issues/195) for an -- example of what can happen if you do not do so.) All of the 'IO'-returning -- functions in "Criterion.Main" make sure that this is done, but other -- functions (such as those in "Criterion.Measurement") do not guarantee this
src/Criterion/Measurement/Types.hs view
@@ -332,7 +332,7 @@ -- | Generate a function that will run an action a given number of times, -- reducing it to normal form each time.-nfIO' :: (a -> b) -> IO a -> (Int64 -> IO ())+nfIO' :: (a -> ()) -> IO a -> (Int64 -> IO ()) nfIO' reduce a = go where go n | n <= 0 = return ()