blaze-html icon indicating copy to clipboard operation
blaze-html copied to clipboard

add gwan to bigtable benchmark

Open redaready opened this issue 15 years ago • 8 comments

https://gist.github.com/878224

feel free to add it in your benchmark.
gwan:http://www.trustleap.com/

redaready avatar Mar 20 '11 09:03 redaready

Hi redaready,

thank you very much for that code. I assume that it will give us a great performance baseline. However, from what I understand of your code you are neither using UTF-8 encoding nor are you HTML escaping the dynamically generated table content. I understand that for the numbers in the bigtable benchmark escaping is unnecessary. However we do the escaping, as the benchmark should reflect the performance in real use cases as good as possible. For many real use cases, its very hard and error prone to get rid of escaping dynamically generated content.

best regards and thanks again, Simon

meiersi avatar Mar 21 '11 07:03 meiersi

I totally agree with you about escaping the content and just updated the code for g-wan 2.0+. I think the string of gwan has the same encoding as the source file.....i am waiting for the more-than-expected release of gwan to test the changes of api and performance.

redaready avatar Mar 23 '11 22:03 redaready

Thanks for updating the code. I had a quick glance at it and I'm surprised that there's no way to do a printf_html_escaped in gwan. If code really has to be written, as you show, then this seems both detrimental to performance (superfluous buffer copies) as well as very risky with respect to buffer overflows.

meiersi avatar Mar 24 '11 09:03 meiersi

hi, did you add g-wan to your benchmarks? how does it perform?

X4 avatar Mar 05 '12 05:03 X4

No we did not do that yet due to a lack of development ressources. We'd however happily accept patches..as usual :-)

meiersi avatar Mar 05 '12 08:03 meiersi

Sure thing, I was just curious because the patch above looked good to me. There's a way to do a printf_html_escaped in gwan, the patch above does exactly that, I think he should've commented it to make it clear. :)

// escapes the content of buffer, which is the desired html
line 23 escape_html(buffer,buffer,100);

// prints the html_escaped (modified) buffer back into the http body
line 24 xbuf_xcat(reply, "<td>%s</td>",buffer); 

to printf into the console you can simply printf("<td>%s</td>",buffer); but xbuf_xcat() is the right way to output into the browser. To run the example you just extract G-WAN into a directory, copy the gist above into whatever.c put it into the csp folder in 0.0.0.0_8080/#0.0.0.0/csp then enter localhost:8080/csp/whatever.c in your browser.

These are other "html_escaping functions" available in G-WAN:

// ============================================================================
// HTML escaping
// ----------------------------------------------------------------------------
u32  url_encode   (u8 *dst, u8 *src, u32 maxdstlen);  // return len
u32  escape_html  (u8 *dst, u8 *src, u32 maxdstlen);  // return len
u32  unescape_html(u8 *str);                          // inplace, return len
int  html2txt     (u8 *html, u8 *text, int maxtxlen); // return len

X4 avatar Mar 05 '12 19:03 X4

Pierre,the creator of gwan, has written a better version cf:https://gist.github.com/2001619

redaready avatar Mar 09 '12 20:03 redaready

Thank's I'll look into that.

meiersi avatar Mar 10 '12 06:03 meiersi