Comments (4)
It's 15% faster with MVar
s on my computer.
from skynet.
Makes sense, as channels are more general than what's needed here.
Results on my laptop: (first one is the MVar
version)
➜ haskell git:(master) ✗ time (./Skynet2 +RTS -N4)
Result: 499999500000 in 1.90832s
( ./Skynet2 +RTS -N4; ) 6.39s user 1.64s system 329% cpu 2.433 total
➜ haskell git:(master) ✗ time (./Skynet +RTS -N4)
Result: 499999500000 in 2.027485s
( ./Skynet +RTS -N4; ) 6.92s user 1.38s system 356% cpu 2.327 total
from skynet.
Also, I would have done this (even though we are not in the actor paradigm now) :
{-# LANGUAGE BangPatterns #-}
module Main (main) where
import Data.Time.Clock (getCurrentTime, diffUTCTime)
import Control.Parallel.Strategies
skynet :: Int -> Int -> Int -> Int
skynet num size dv
| size == 1 = num
| otherwise = sum (parMap rpar subcompute [0 .. dv-1])
where
subcompute i = let subNum = num + i * sizeDiv
sizeDiv = size `quot` dv
in skynet subNum sizeDiv dv
main :: IO ()
main = do
start <- getCurrentTime
let !result = skynet 0 1000000 10
end <- getCurrentTime
putStrLn $ concat ["Result: ", show result, " in ", show (diffUTCTime end start)]
And it is much faster (0.027s on my computer).
from skynet.
@bartavelle thank you for submitting these, I am going to PR this and other fixes!
from skynet.
Related Issues (20)
- Alternative Go version HOT 5
- Use monotonic_time for Erlang
- What, if anything, have you done to thwart CPU frequency scaling? HOT 1
- Tuning the Erlang VM HOT 2
- .NET Native version HOT 1
- Update results in README.md to reflect current code HOT 1
- Add Service Fabric results
- Table of results
- Results re-run HOT 5
- License?
- Prolog version! HOT 2
- WIP Rust version HOT 1
- Is .NET TPL version synchronous?
- rust-jobsteal results HOT 1
- Interesting Haskell Results HOT 3
- Can't compile `rust-coroutine` with Rust 1.8.0
- Use Project Orleans for .Net
- Haskell Stack swallows RTS flags HOT 1
- Intel TBB version?
- Crystal version doesn't compile with 1.4.1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from skynet.