[Haskell-iPhone] FFI calls into Haskell taking a long time

James Parker jp at jamesparker.me
Fri Apr 8 18:47:10 UTC 2016


Hi,

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. 

Are there any tools to benchmark where time is being spent on the device? Is there some way to enable -enable-library-profiling? 

Thanks,

James

> On Apr 6, 2016, at 7:45 PM, Manuel M T Chakravarty <chak at justtesting.org> wrote:
> 
> 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.
> 
> Manuel
> 
>> James Parker <jp at jamesparker.me>:
>> 
>> Hi,
>> 
>> 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. 
>> 
>> 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. 
>> 
>> gen :: MonadRandom m => m (RSA.PublicKey, RSA.PrivateKey)
>> gen = withCPRG $ \prg -> return $ RSA.generate prg 256 65537
>> 
>> instance MonadRandom IO where
>>   type MonadCPRG IO = SystemRNG
>> 
>>   withCPRG f = do
>>       entropy <- createEntropyPool
>>       (res, _) <- f $ cprgCreate entropy
>>       return res
>> 
>> I’d appreciate any help.
>> 
>> Thanks!
>> 
>> James
>> _______________________________________________
>> iPhone mailing list
>> iPhone at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/iphone
> 



More information about the iPhone mailing list