简体   繁体   中英

Is Cairo Graphics slower in other languages than c? In Haskell for example?

I've been using Cairo Graphics in c for a while and I'd like to use it in a more high-level language (namely Haskell, I've also tried Python). It works but truthfully, I don't have a clear picture in my head on how that works internally.

When my Haskell source is compiled, is the cairo-related part of the object file the same as if it had been compiled from ac source ?

Will cairo_line_to (cr, 100, 100) in c be compiled into the same machine code as LineTo 100 100 in Haskell? Will the performance be the same?

There's some FFI overhead from most languages calling C libraries. It's a small (usually-)constant overhead on each call to a C function, but it will add up if you make lot of calls.

This isn't unique to calling C, for what it's worth. Any crossing of memory management systems does the job. That's why modern OpenGL recommends doing as much as possible in calls that send data to graphics memory in giant blocks, instead of one triangle at a time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM