Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Added microbenchmark for spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
kayceesrk committed Mar 6, 2014
1 parent dad1f94 commit 4914566
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 0 deletions.
16 changes: 16 additions & 0 deletions trunk/testing/benchmarks/micro-benchmarks/spawn-test/Makefile
@@ -0,0 +1,16 @@
all: mlton ghc host par

mlton: spawn-sml-seq.mlb
mlton spawn-sml-seq.mlb

host: spawn-sml-host.sml
../../../../build/bin/mlton spawn-sml-host.sml

par: spawn-sml-par.sml
../../../../build/bin/mlton spawn-sml-par.sml

ghc: spawn-ghc.hs
ghc --make -O2 -threaded spawn-ghc.hs -o spawn-ghc

clean:
rm -f spawn-sml-seq spawn-sml-host spawn-ghc spawn-sml-par *.o *.hi *~
@@ -0,0 +1,9 @@
{-# Language ScopedTypeVariables #-}
import Control.Concurrent
import System.Environment
import Control.Monad

main = do
args <- getArgs
let numThreads::Int = read $ head args
replicateM_ numThreads $ forkIO $ return ()
@@ -0,0 +1,8 @@
open MLton.Pacml

fun main 0 = OS.Process.exit OS.Process.success
| main n = (ignore (spawn (fn () => ()));
main (n-1))

val n = valOf (Int.fromString (hd (CommandLine.arguments ()))) handle _ => 600
val _ = run (fn () => main n)
@@ -0,0 +1,8 @@
open MLton.Pacml

fun main 0 = OS.Process.exit OS.Process.success
| main n = (ignore (spawnParasite (fn () => ()));
main (n-1))

val n = valOf (Int.fromString (hd (CommandLine.arguments ()))) handle _ => 600
val _ = run (fn () => main n)
@@ -0,0 +1,6 @@
local
$(SML_LIB)/basis/basis.mlb
$(SML_LIB)/cml/cml.mlb
in
spawn-sml-seq.sml
end
@@ -0,0 +1,23 @@

structure Main =
struct
open CML

fun spawnHelper 0 = RunCML.shutdown OS.Process.success
| spawnHelper n = (ignore (spawn (fn () => ()));
spawnHelper (n-1))

fun doit n =
RunCML.doit
(fn () =>
let
val _ = spawnHelper n
in
()
end,
SOME (Time.fromMilliseconds 10))
end


val n = valOf (Int.fromString (hd (CommandLine.arguments ()))) handle _ => 600
val _ = Main.doit n

0 comments on commit 4914566

Please sign in to comment.