Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
Packages
Cabal
Commits
7904fb23
Commit
7904fb23
authored
Feb 16, 2016
by
Mikhail Glushenkov
Browse files
Tweak mtime calibration a bit.
parent
0e5eaf0d
Changes
1
Hide whitespace changes
Inline
Side-by-side
cabal-install/tests/UnitTests.hs
View file @
7904fb23
...
...
@@ -72,7 +72,7 @@ calibrateMtimeChangeDelay :: IO Int
calibrateMtimeChangeDelay
=
do
withTempDirectory
silent
"."
"calibration-"
$
\
dir
->
do
let
fileName
=
dir
</>
"probe"
mtimes
<-
forM
[
1
..
10
]
$
\
(
i
::
Int
)
->
time
$
do
mtimes
<-
forM
[
1
..
25
]
$
\
(
i
::
Int
)
->
time
$
do
writeFile
fileName
$
show
i
t0
<-
getModTime
fileName
let
spin
j
=
do
...
...
@@ -80,11 +80,18 @@ calibrateMtimeChangeDelay = do
t1
<-
getModTime
fileName
unless
(
t0
<
t1
)
(
spin
$
j
+
1
)
spin
(
0
::
Int
)
let
mtimeChange
=
maximum
mtimes
putStrLn
$
"Mtime delay calibration completed, calculated delay: "
++
(
show
$
fromIntegral
mtimeChange
/
(
1000.0
::
Double
))
++
" ms."
return
$
min
1000000
(
max
10000
mtimeChange
)
let
mtimeChange
=
maximum
mtimes
mtimeChange'
=
min
1000000
$
(
max
10000
mtimeChange
)
*
2
notice
normal
$
"File modification time resolution calibration completed, "
++
"maximum delay observed: "
++
(
show
.
toMillis
$
mtimeChange
)
++
" ms. "
++
"Will be using delay of "
++
(
show
.
toMillis
$
mtimeChange'
)
++
" for test runs."
return
mtimeChange'
where
toMillis
::
Int
->
Double
toMillis
x
=
fromIntegral
x
/
(
1000.0
::
Double
)
time
::
IO
()
->
IO
Int
time
act
=
do
t0
<-
getCurrentTime
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment