Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
dad1bf2d
Commit
dad1bf2d
authored
Apr 21, 2011
by
Simon Peyton Jones
Browse files
Test Trac
#5113
parent
81525f94
Changes
3
Hide whitespace changes
Inline
Side-by-side
testsuite/tests/ghc-regress/perf/should_run/T5113.hs
0 → 100644
View file @
dad1bf2d
{-# LANGUAGE BangPatterns #-}
module
Main
where
import
Data.Array.Base
(
unsafeRead
,
unsafeWrite
)
import
Data.Array.ST
import
Data.Array.Unboxed
import
Control.Monad.ST
main
=
print
(
divisorCounts
1000000
!
342
)
isqrt
::
Int
->
Int
isqrt
n
=
floor
(
sqrt
$
fromIntegral
n
)
divisorCounts
::
Int
->
UArray
Int
Int
divisorCounts
n
=
runSTUArray
$
do
let
!
rt
=
isqrt
n
darr
<-
newArray
(
0
,
n
)
1
::
ST
s
(
STUArray
s
Int
Int
)
let
inc
i
=
unsafeRead
darr
i
>>=
\
k
->
unsafeWrite
darr
i
(
k
+
1
)
note
step
i
|
i
>
n
=
return
()
|
otherwise
=
do
inc
i
note
step
(
i
+
step
)
count
j
|
j
>
rt
=
return
()
|
otherwise
=
do
note
(
2
*
j
)
(
j
*
j
)
count
(
j
+
2
)
note
2
4
count
3
return
darr
testsuite/tests/ghc-regress/perf/should_run/T5113.stdout
0 → 100644
View file @
dad1bf2d
2
testsuite/tests/ghc-regress/perf/should_run/all.T
View file @
dad1bf2d
...
...
@@ -107,3 +107,11 @@ test('T149',
run_command
,
['
$MAKE -s --no-print-directory T149
'])
test
('
T5113
',
[
stats_num_field
('
bytes allocated
',
8000000
,
9000000
),
only_ways
(['
normal
'])
],
compile_and_run
,
['
-O
'])
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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