使用c ++中函数的执行时间绘制图形
Drawing a graph using executing time of a function in c++
我多次调用某些函数 (5000-10000) 并测量每次完成函数执行所需的时间。
例如:使用 10 个整数、11 个整数、1000 个整数进行二分查找...
现在我想画出完成搜索每一步需要多少时间的图表。
我有 X 的整数数量和 Y 的时间。但我不知道如何将这些点连接起来制作图表,visual studio 2015 中是否有任何函数或库可以帮助我画个图?像 borland 中的 "graphics.h"
编辑:使用 windows 10 和 visual studio 2015
标准 C++11 或 C++14 没有任何图形库。
但你应该考虑使用 Qt, a free software cross-platform GUI library for C++. I guess that you'll be happy in using Qt graphics view framework. You could also consider some other, perhaps OS specific, widget toolkit. Or just output a 2D graphics using libcairo。
另一种可能是在它们之间输出一些文本文件(GNUplot, in JSON, in SVG, for some spreadsheet in CSV, etc...) and use some external program to display that graph (in textual format). You could even use some inter-process communication (e.g. some FIFO or pipeline, with _popen
or better)。
顺便说一句 Windows 是 AFAIK 不是实时的 OS,但是您并不像您评论的那样真正需要实时,您只需要一些交互性。恕我直言,流水线化到 GNUplot 非常容易(至少在 Linux 上如此,可能在 Windows 上也是如此......)。
我多次调用某些函数 (5000-10000) 并测量每次完成函数执行所需的时间。
例如:使用 10 个整数、11 个整数、1000 个整数进行二分查找... 现在我想画出完成搜索每一步需要多少时间的图表。
我有 X 的整数数量和 Y 的时间。但我不知道如何将这些点连接起来制作图表,visual studio 2015 中是否有任何函数或库可以帮助我画个图?像 borland 中的 "graphics.h"
编辑:使用 windows 10 和 visual studio 2015
标准 C++11 或 C++14 没有任何图形库。
但你应该考虑使用 Qt, a free software cross-platform GUI library for C++. I guess that you'll be happy in using Qt graphics view framework. You could also consider some other, perhaps OS specific, widget toolkit. Or just output a 2D graphics using libcairo。
另一种可能是在它们之间输出一些文本文件(GNUplot, in JSON, in SVG, for some spreadsheet in CSV, etc...) and use some external program to display that graph (in textual format). You could even use some inter-process communication (e.g. some FIFO or pipeline, with _popen
or better)。
顺便说一句 Windows 是 AFAIK 不是实时的 OS,但是您并不像您评论的那样真正需要实时,您只需要一些交互性。恕我直言,流水线化到 GNUplot 非常容易(至少在 Linux 上如此,可能在 Windows 上也是如此......)。