Ticket #1685 (closed bug: worksforme)

Opened 4 years ago

Last modified 3 years ago

getCPUTime does not work in general

Reported by: iampure@… Owned by:
Priority: normal Milestone: 6.8.1
Component: GHCi Version: 6.7
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Difficulty: Unknown
Test Case: Blocked By:
Blocking: Related Tickets:

Description

With

fromPicoSeconds picoseconds =
  let (n,k) = divMod picoseconds (10^12) 
  in  normalizeTimeDiff (diffClockTimes (TOD n k) (TOD 0 0))

Then evaluate the following:

replicateM 1000 $ liftM fromPicoSeconds getCPUTime

They all return the same number of picoseconds. Computers aren't that fast. I expected to see at least some different numbers.

Change History

Changed 4 years ago by igloo

  • status changed from new to closed
  • resolution set to worksforme

Again: Please do not set the milestone when filing bugs.

See  http://hackage.haskell.org/trac/ghc/wiki/ReportABug for details.

getCPUTime looks fine to me. Note that not all systems will necessarily be able to provide timing information with as much accuracy as the Haskell type allows:

Prelude> :m + System.CPUTime Control.Monad Data.List
Prelude Data.List Control.Monad System.CPUTime> do xs <- replicateM 10000 getCPUTime; print $ all (head xs ==) xs; mapM_ print $ [ (head x, length x) | x <- group xs ]
False
(876054000000,2044)
(880054000000,2411)
(884055000000,2397)
(888055000000,1829)
(892055000000,1319)
Prelude Data.List Control.Monad System.CPUTime> 

Changed 4 years ago by igloo

  • milestone changed from 6.8 branch to 6.8.1

Changed 3 years ago by simonmar

  • architecture changed from Unknown to Unknown/Multiple

Changed 3 years ago by simonmar

  • os changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.