Golang – 单个操作的持续时间

huangapple go评论60阅读模式
英文:

Golang - Duration for individual operation

问题

我有一个算法,它对PNG图像中的一个像素执行数学运算,然后根据结果绘制一个新的图像。我想显示整个过程的持续时间,然后更具体地显示每个单独像素的时间。

算法的结果显示在终端上:

>> 图像像素:921600 -- 宽度 x 高度:960 - 960
>> 经过的时间(毫秒):165.913052ms

我最初的想法是输出 elapsed / totalPixels 的结果,但由于类型不正确而导致错误。

英文:

I have an algorithm that performs a mathematical operation on a pixel within a PNG image, it then draws a new image from the result. I'm wanting to show the duration time for the entire process and then be more specific and show the time time taken for each individual pixel.

The result of the algorithm is shown in the terminal:

>> image pixels:  921600  -- width x height: 960 - 960
>> time elapsed (m-seconds) :  165.913052ms

My initial thinking was to output the result of elapsed / totalPixels however this results in an error due to incorrect types.

答案1

得分: 0

尝试转换类型

elapsed/time.Duration(totalPixels)

或者

int(elapsed)/totalPixels
英文:

Try convert type

elapsed/time.Duration(totalPixels)

or

int(elapsed)/totalPixels

huangapple
  • 本文由 发表于 2016年4月16日 22:45:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/36665591.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定