Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

getCPUTime only returns two values (0 or 15625000000) - is this correct?

It seems that it always return 0 or 15625000000 .

import System.CPUTime

main  =  do         
    print =<< getCPUTime
    getLine
    print =<< getCPUTime
    getLine
    return ()

Execution

>>time.exe
15625000000

15625000000


>>time.exe
0

0


>>time.exe
0

15625000000


>>time.exe
0

0

I'm on Windows, I think it's a platform related.

like image 890
MdxBhmt Avatar asked Mar 22 '23 11:03

MdxBhmt


1 Answers

From hoogle

getCPUTime :: IO Integer

base System.CPUTime

Computation getCPUTime returns the number of picoseconds CPU time used by the current program. The precision of this result is implementation-dependent.

It could be that windows doesn't have an accurate implementation and returns a 0 instead of the number of picoseconds, note i do not see this behavior on linux or osx.

like image 195
pyCthon Avatar answered Apr 06 '23 00:04

pyCthon