简体   繁体   English

Cairo Graphics在其他语言中比c慢吗? 以Haskell为例?

[英]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). 我已经在c中使用了Cairo Graphics一段时间了,我想在更高级的语言中使用它(即Haskell,我也尝试过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 ? 编译我的Haskell源时,对象文件中与cairo相关的部分是否与从ac源编译的相同?

Will cairo_line_to (cr, 100, 100) in c be compiled into the same machine code as LineTo 100 100 in Haskell? c中的cairo_line_to (cr, 100, 100)会被编译为与Haskell中的LineTo 100 100相同的机器代码? Will the performance be the same? 性能是否相同?

There's some FFI overhead from most languages calling C libraries. 大多数语言调用C库都会产生一些FFI开销。 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. 每次调用C函数时,这是一个小的(通常)常量开销,但如果你进行大量调用,它会加起来。

This isn't unique to calling C, for what it's worth. 这不是调用C的唯一因素,因为它的价值。 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. 这就是为什么现代OpenGL建议尽可能多地在以巨大块发送数据到图形内存的调用中,而不是一次一个三角形。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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