[erlang-questions] High cpu usage with erlycairo

pablo platt pablo.platt@REDACTED
Tue Jul 31 18:41:33 CEST 2012


Hi,

Cairo is a 2D graphics library.
http://www.cairographics.org/
erlycairo uses a c-node to talk to cairo.
http://code.google.com/p/erlycairo/
I'm using erlycairo to draw an image on the server.
I'm sending a path with ~40 points every 1/2 second and draw it on a
800x1200 px canvas.

I'm getting 60% cpu load.
When removing the last part which writes the canvas context to a png
stream, I'm getting 20% cpu load.
Is there a reason why it produces such a big load on the cpu?
Is there something I can do to decrease it?
Are there other options to draw on a canvas which might be better?

This is the code I'm using:

{ok, Ctx} = erlycairo_server:new_image_blank(800, 1200),
% load previous stream (not shown)
erlycairo_server:set_source_rgba(Ctx, R, G, B, 1.0),
erlycairo_server:move_to(Ctx, X0, Y0),
lists:foreach(fun({X, Y}) ->
  erlycairo_server:line_to(Ctx, X, Y)
end, Path),
erlycairo_server:set_line_width(Ctx, 1),
erlycairo_server:stroke(Ctx),
{ok, Stream} = erlycairo_server:write_to_png_stream(Ctx),
% save the stream (not shown)
erlycairo_server:close_image(Ctx).

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120731/bcd2b455/attachment.htm>


More information about the erlang-questions mailing list