<br><br>On Tuesday, January 7, 2014, Branimir Maksimovic  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div bgcolor="#FFFFFF" text="#000000">
    <div>On 01/08/2014 04:15 AM, Bob Ippolito
      wrote:<br>
    </div>
    <blockquote type="cite">On Tuesday, January 7, 2014, Branimir Maksimovic
      wrote:<br>
      <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 01/07/2014
        09:39 PM, Bob Ippolito wrote:<br>
        <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
          Here's a much simpler implementation for that sort of pattern,
          using channels to fan out work to threads. I added a
          dependency on Criterion because getCPUTime is basically
          useless for this kind of measurement on Mac OS X since it
          doesn't include the time that the process spent waiting on IO:<br>
        </blockquote>
        Great, thank you very much. You gave me material for learning ;)<br>
        However, my version is significantly faster when compiling
        without -threaded.<br>
        With -threaded option, your version is much faster than mine,
        but both are significantly slower<br>
        then compile without -threaded.<br>
      </blockquote>
      <div><br>
      </div>
      <div>Happy to look into it, I didn't have time today to do
        benchmarks (and Mac OS X is the worst platform to do this kind
        of testing on regardless of language, its network stack is
        inconsistent at best). I need to know more:</div>
      <div><br>
      </div>
      <div>How exactly are you compiling?</div>
    </blockquote>
    <br>
    ghc-7.6.3 --make -O2 client.hs<br>
    <br>
    <blockquote type="cite">
      <div>Which OS?</div>
    </blockquote>
    <br>
    Ubuntu 13.10 with 3.13-rc7 kernel.<br>
    <br>
    <blockquote type="cite">
      <div>What version of GHC and Haskell Platform?</div>
    </blockquote>
    <br>
    bmaxa@maxa:~$ apt-cache policy haskell-platform<br>
    haskell-platform:<br>
      Installed: 2013.2.0.0<br>
      Candidate: 2013.2.0.0<br>
      Version table:<br>
     *** 2013.2.0.0 0<br>
            500 <a href="http://archive.ubuntu.com/ubuntu/" target="_blank">http://archive.ubuntu.com/ubuntu/</a> saucy/universe amd64
    Packages<br>
            100 /var/lib/dpkg/status<br>
    <br>
    <br>
    <blockquote type="cite">
      <div> What is the exact command line you execute it with?</div>
    </blockquote>
    <br>
    time ./client maxa 5055 1000 100000</div></blockquote><div><br></div><div>What happens if you add +RTS -N to the end of that command line?</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000"><br>
    <br>
    <blockquote type="cite">
      <div>What timings do you get?</div>
    </blockquote>
    with your version:<br>
    real    0m4.235s<br>
    user    0m1.589s<br>
    sys    0m2.642s<br>
    <br>
    with my version<br>
    real    0m3.010s<br>
    user    0m0.590s<br>
    sys    0m2.417s<br>
    that is, of course, without -threaded<br>
    <br>
    <blockquote type="cite">
      <div>What's the code for the server are you connecting to?</div>
    </blockquote>
    import Network (listenOn,PortID(..))<br>
    import Network.Socket (accept,close)<br>
    import Network.Socket.ByteString<br>
    import System.Environment<br>
    import Control.Concurrent (forkIO)<br>
    <br>
    main = do<br>
        n <- getArgs<br>
        let nn = (read.head) n :: Int<br>
        putStrLn $ "Listening on " ++ show nn<br>
        sock <- listenOn $ PortNumber $ fromIntegral nn<br>
        serve sock<br>
        <br>
    serve sock = do<br>
        (s,_) <- accept sock<br>
        forkIO $ process s<br>
        serve sock<br>
    <br>
    process sock = do<br>
        buf <- recv sock 1024<br>
        sendAll sock buf<br>
        close sock<br>
    <br>
    <blockquote type="cite">
      <div>Loopback, local network, or internet?</div>
    </blockquote>
    <br>
    loopback. Testing is on same computer.<br>
    <br>
    Thanks!<br>
  </div></blockquote><div><br></div><div>Great, I'll look closer later tonight or tomorrow morning. </div><div> </div>