<div dir="ltr">sure, sorry should have done at the first place. Basically I have several similar calls like one below. This one should be the heaviest one.<div><br></div><div>--scotty:</div><div><div>post "/setmoduletable" $ do</div>
<div><span class="" style="white-space:pre">            </span>b <- body</div><div><span class="" style="white-space:pre">               </span>let queryString = tableArrayInDataToJSON b</div><div><span class="" style="white-space:pre">         </span>case queryString of</div>
<div><span class="" style="white-space:pre">                    </span>Nothing -> text $ "error parsing json! "</div><div><span class="" style="white-space:pre">                      </span>Just (ArrayDataIn tablename columnsCnt rowsCnt values) -> do</div>
<div><span class="" style="white-space:pre">                            </span>result <- liftIO $ FM.setmoduletable tablename columnsCnt rowsCnt values</div><div><span class="" style="white-space:pre">                                </span>let resultInt = fromIntegral $ result::Int</div>
<div><span class="" style="white-space:pre">                            </span>json $ ReturnIntData resultInt</div></div><div><br></div><div><br></div><div>--json conversions</div><div><div>tableArrayInDataToJSON :: L.ByteString -> Maybe ArrayDataIn</div>
<div>tableArrayInDataToJSON rawJson = retValue</div><div><span class="" style="white-space:pre">    </span>where</div><div><span class="" style="white-space:pre">              </span>json = decode rawJson :: Maybe ArrayDataIn</div><div>
<span class="" style="white-space:pre">               </span>retValue = case json of</div><div><span class="" style="white-space:pre">                    </span>Nothing -> Nothing</div><div><span class="" style="white-space:pre">                      </span>Just a -> Just a</div>
</div><div><br></div><div><br></div><div><div>data ArrayDataIn = ArrayDataIn{</div><div><span class="" style="white-space:pre">     </span>tablename :: !String</div><div><span class="" style="white-space:pre">       </span>,columnscount :: Int</div>
<div><span class="" style="white-space:pre">    </span>,rowscount :: Int</div><div><span class="" style="white-space:pre">  </span>,values :: [Double]</div><div>}deriving (Show,Generic)</div><div><br></div><div>instance FromJSON ArrayDataIn</div>
<div>instance ToJSON ArrayDataIn</div></div><div><br></div><div>--ffi</div><div><br></div><div><div>foreign import stdcall safe "setmoduletable" c_setmoduletable :: CString -> CInt -> Ptr CDouble -> CInt -> CInt -> CInt -> IO CInt</div>
</div><div><br></div><div><br></div><div><div>setmoduletable :: String -> Int -> Int -> [Double] -> IO CInt</div><div>setmoduletable param columns rows array = do</div><div><span class="" style="white-space:pre">        </span>let cParamLength = fromIntegral $ length param ::CInt</div>
<div><span class="" style="white-space:pre">    </span>    cColumns = fromIntegral $ columns ::CInt</div><div><span class="" style="white-space:pre">       </span>    cRows = fromIntegral $ rows ::CInt</div><div><span class="" style="white-space:pre">     </span>    cTable = [realToFrac x ::CDouble | x <- array]</div>
<div><span class="" style="white-space:pre">    </span>    firstTimeStepAfterRestart = 0::CInt</div><div><span class="" style="white-space:pre">    </span>cParam <- newCString param</div><div><span class="" style="white-space:pre">      </span>cTablePtr <- newArray cTable</div>
<div><span class="" style="white-space:pre">    </span>result <- c_setmoduletable cParam cParamLength cTablePtr cColumns cRows firstTimeStepAfterRestart</div><div><span class="" style="white-space:pre">       </span>free cTablePtr</div>
<div><span class="" style="white-space:pre">    </span>free cParam</div><div><span class="" style="white-space:pre">        </span>return result</div></div><div><br></div><div><br></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">
On Sat, Apr 5, 2014 at 3:01 PM, John Wiegley <span dir="ltr"><<a href="mailto:johnw@fpcomplete.com" target="_blank">johnw@fpcomplete.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div class="">>>>>> Miro Karpis <<a href="mailto:miroslav.karpis@gmail.com">miroslav.karpis@gmail.com</a>> writes:<br>
<br>
> I tried to profile it but so far I can see that the bottleneck is Aeson<br>
> (please correct me if I'm wrong). Is there a way how to optimise it? The<br>
> data I'm sending via JSON are very small, so that can not be the problem.<br>
<br>
</div>Can you share any of your code with us?<br>
<br>
John<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br></div>