<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">Hi,</div><div class=""><br class=""></div><div class="">I’ve been looking into this some more. It looks like <a href="http://hackage.haskell.org/package/crypto-numbers-0.2.7/docs/src/Crypto-Number-Prime.html#generatePrime" class="">generatePrime</a> is causing the slowdown. I manually added some benchmarking and logging to this function and its dependencies (I removed the gmp code). Here is the output from the iOS version: </div><div class=""><br class=""></div><a href="http://lpaste.net/6160729019554725888" class="">http://lpaste.net/6160729019554725888</a><div class=""><br class=""></div><div class="">Here is the output run natively on my machine: <br class=""><div class=""><br class=""></div><div class=""><a href="http://lpaste.net/2971101072195584000" class="">http://lpaste.net/2971101072195584000</a></div><div class=""><br class=""></div><div class="">As you can see, the iOS version is much slower (about 75x). What differences are there when cross-compiling for iOS that might explain this difference? It looks like the iOS version might be using integer-simple instead of gmp? Are there any other differences?</div><div class=""><br class=""></div><div class="">Thanks!</div><div class=""><br class=""></div><div class="">James</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 8, 2016, at 2:47 PM, James Parker <<a href="mailto:jp@jamesparker.me" class="">jp@jamesparker.me</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Hi,<br class=""><br class="">Sorry, it took a while to get running on the device. Yes, I still get the slowdown on the device. XCode is reporting 99-100% CPU usage while memory stays pretty consistent (around 18MB). This is similar to what I was seeing on the simulator. <br class=""><br class="">Are there any tools to benchmark where time is being spent on the device? Is there some way to enable -enable-library-profiling? <br class=""><br class="">Thanks,<br class=""><br class="">James<br class=""><br class=""><blockquote type="cite" class="">On Apr 6, 2016, at 7:45 PM, Manuel M T Chakravarty <<a href="mailto:chak@justtesting.org" class="">chak@justtesting.org</a>> wrote:<br class=""><br class="">Did you try on the device? The simulator is a strange beast and its performance may not be representative of what you get on a real device.<br class=""><br class="">Manuel<br class=""><br class=""><blockquote type="cite" class="">James Parker <<a href="mailto:jp@jamesparker.me" class="">jp@jamesparker.me</a>>:<br class=""><br class="">Hi,<br class=""><br class="">I’m exporting a Haskell function that generates RSA keys for an iOS application. I’m using the crypto-pubkey and crypto-random packages. Unfortunately, the key generation is taking an extremely long time (around 5 minutes) when run in the simulator (XCode 7.2.1). When running Haskell code through Criterion, key generation only takes 110ms. When benchmarking a c program that links the Haskell FFI library (on my x86 laptop), key generation takes about 130ms. <br class=""><br class="">Does anyone have any ideas why this is so much slower on the simulator? I thought maybe there was an issue with running out of randomness, so I tried creating a fixed seed by using `createTestEntropyPool`, but this did not make any difference. I’ve included the relevant key generate function below. <br class=""><br class="">gen :: MonadRandom m => m (RSA.PublicKey, RSA.PrivateKey)<br class="">gen = withCPRG $ \prg -> return $ RSA.generate prg 256 65537<br class=""><br class="">instance MonadRandom IO where<br class="">  type MonadCPRG IO = SystemRNG<br class=""><br class="">  withCPRG f = do<br class="">      entropy <- createEntropyPool<br class="">      (res, _) <- f $ cprgCreate entropy<br class="">      return res<br class=""><br class="">I’d appreciate any help.<br class=""><br class="">Thanks!<br class=""><br class="">James<br class="">_______________________________________________<br class="">iPhone mailing list<br class=""><a href="mailto:iPhone@haskell.org" class="">iPhone@haskell.org</a><br class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/iphone<br class=""></blockquote><br class=""></blockquote><br class=""></div></div></blockquote></div><br class=""></div></div></body></html>