<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, wren</div><div class=""><br class=""></div><div class="">BTW, I think it’s a good idea to host your code on github which is easier to send patch .etc, can you mirror your bytestring-lexing repo to github? </div><div class=""><br class=""></div><div class="">happy hacking!</div><div class=""><br class=""></div><div class="">winter</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Oct 10, 2016, at 11:39, winter <<a href="mailto:drkoster@qq.com" class="">drkoster@qq.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><blockquote type="cite" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">On Oct 9, 2016, at 13:56, wren romano <<a href="mailto:winterkoninkje@gmail.com" class="">winterkoninkje@gmail.com</a>> wrote:<br class=""><br class="">On Sun, Oct 2, 2016 at 3:17 AM, 韩冬(基础平台部) <<a href="mailto:handongwinter@didichuxing.com" class="">handongwinter@didichuxing.com</a>> wrote:<br class=""><blockquote type="cite" class="">Hi wren!<br class=""><br class="">Yes, i noticed that attoparsec's numeric parsers are slow. I have a benchmark set to compare attoparsec and binary-parsers on different sample JSON files, it's on github: <a href="https://github.com/winterland1989/binary-parsers" class="">https://github.com/winterland1989/binary-parsers</a>.<br class=""><br class="">I'm pretty sure bytestring-lexing helped a lot, for example, the average decoding speed improvement is around 20%, but numeric only benchmarks(integers and numbers) improved by 30% !<br class=""></blockquote><br class="">So still some substantial gains for non-numeric stuff, nice!<br class=""><br class=""><blockquote type="cite" class="">Parsing is just a part of JSON decoding, lots of time is spent on unescaping, .etc. So the parser's improvement is quite large IMHO.<br class=""><br class="">BTW, can you provide a version of lexer which doesn't check whether a Word is a digit? In binary-parsers i use something like `takeWhile isDigit` to extract the input ByteString, so there's no need to verify this in lexer again. Maybe we can have another performance improvement.<br class=""></blockquote><br class="">I suppose I could, but then it wouldn't be guaranteed to return<br class="">correct answers. The way things are set up now, the intended workflow<br class="">is that wherever you're expecting a number, you should just hand the<br class="">ByteString over to bytestring-lexing (i.e., not bother<br class="">scanning/pre-lexing via `takeWhile isDigit`) and it'll give back the<br class="">answer together with the remainder of the input. This ensures that you<br class="">don't need to do two passes over the characters. So, for Attoparsec<br class="">itself you'd wrap it up with something like:<br class=""><br class="">  decimal :: Integral a => Parser a<br class="">  decimal =<br class="">      get >>= \bs -><br class="">      case readDecimal bs of<br class="">      Nothing -> fail "error message"<br class="">      Just (a, bs') -> put bs' >> return a<br class=""><br class="">Alas `get` isn't exported[1], but you get the idea. Of course, for<br class="">absolute performance you may want to inline all the combinators to see<br class="">if there's stuff you can get rid of.<br class=""><br class="">The only reason for scanning ahead is in case you're dealing with lazy<br class="">bytestrings and so need to glue them together in order to use<br class="">bytestring-lexing. Older versions of the library did have support for<br class="">lazy bytestrings, but I removed it because it was bitrotten and<br class="">unused. But if you really need it, I can add new variants of the<br class="">lexers for dealing with the possibility of requesting new data when<br class="">the input runs out.<br class=""><br class=""><br class="">[1] <<a href="http://hackage.haskell.org/package/attoparsec-0.13.1.0/docs/src/Data-Attoparsec-ByteString-Internal.html#get" class="">http://hackage.haskell.org/package/attoparsec-0.13.1.0/docs/src/Data-Attoparsec-ByteString-Internal.html#get</a>><br class=""><br class="">--<span class="Apple-converted-space"> </span><br class="">Live well,<br class="">~wren<br class="">_______________________________________________<br class="">Haskell-Cafe mailing list<br class="">To (un)subscribe, modify options or view archives go to:<br class=""><a href="http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe" class="">http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe</a><br class="">Only members subscribed via the mailman list are allowed to post.<br class=""></blockquote><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""></div></blockquote></div><br class=""></body></html>