- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我已经实现了一些可以是 viewed here 的屏幕捕获代码
我正在使用 this article 中的 GetTimeInNanoseconds
该函数每 100 毫秒调用一次。我已经计算了执行部分功能所需的毫秒数,即:
screenShotStart = GetTimeInNanoseconds();
CGImageRef image = CGWindowListCreateImage(rect, kCGWindowListOptionIncludingWindow|kCGWindowListOptionOnScreenBelowWindow, 0, kCGWindowImageDefault);
CGImageRelease(image);
screenShotStop = GetTimeInNanoseconds();
screenShotElapsed = screenShotStop - screenShotStart;
/* Current Delta Time */
screenShotElapsedF = ((float) screenShotElapsed)/1000000.0f;
/* Smooth Delta Time */
screenShotTime = 0.9f*screenShotTime + 0.1f*screenShotElapsedF;
下面的时间测量显示了结果。我很惊讶它有多慢,我想知道为什么。有经验丰富的 Cocoa/Core Graphics OSX 开发人员可以向我解释一下吗?并可能告诉我应该如何修复它?
平滑:以毫秒为单位的平均增量时间。Current:最新的,最新的增量时间,以毫秒为单位。
Screenshot profile : 0.242122ms (smooth) | 2.421224ms (current)
Screenshot profile : 0.970972ms (smooth) | 7.530621ms (current)
Screenshot profile : 1.421471ms (smooth) | 5.475956ms (current)
Screenshot profile : 2.172416ms (smooth) | 8.930922ms (current)
Screenshot profile : 2.840984ms (smooth) | 8.858095ms (current)
Screenshot profile : 3.633541ms (smooth) | 10.766552ms (current)
Screenshot profile : 4.383532ms (smooth) | 11.133454ms (current)
Screenshot profile : 4.876161ms (smooth) | 9.309816ms (current)
Screenshot profile : 5.043479ms (smooth) | 6.549345ms (current)
Screenshot profile : 5.465037ms (smooth) | 9.259055ms (current)
Screenshot profile : 5.709429ms (smooth) | 7.908960ms (current)
Screenshot profile : 5.971393ms (smooth) | 8.329066ms (current)
Screenshot profile : 6.127830ms (smooth) | 7.535762ms (current)
Screenshot profile : 6.533566ms (smooth) | 10.185198ms (current)
Screenshot profile : 6.661420ms (smooth) | 7.812104ms (current)
Screenshot profile : 6.648901ms (smooth) | 6.536235ms (current)
Screenshot profile : 6.564128ms (smooth) | 5.801169ms (current)
Screenshot profile : 6.946393ms (smooth) | 10.386786ms (current)
Screenshot profile : 7.231448ms (smooth) | 9.796943ms (current)
Screenshot profile : 7.408576ms (smooth) | 9.002735ms (current)
Screenshot profile : 7.901027ms (smooth) | 12.333084ms (current)
Screenshot profile : 7.832513ms (smooth) | 7.215887ms (current)
Screenshot profile : 8.077989ms (smooth) | 10.287273ms (current)
Screenshot profile : 8.032367ms (smooth) | 7.621767ms (current)
Screenshot profile : 8.203003ms (smooth) | 9.738728ms (current)
Screenshot profile : 8.525432ms (smooth) | 11.427292ms (current)
Screenshot profile : 8.672282ms (smooth) | 9.993936ms (current)
Screenshot profile : 8.818027ms (smooth) | 10.129727ms (current)
Screenshot profile : 8.968993ms (smooth) | 10.327700ms (current)
Screenshot profile : 9.755873ms (smooth) | 16.837791ms (current)
Screenshot profile : 10.098254ms (smooth) | 13.179691ms (current)
Screenshot profile : 10.007771ms (smooth) | 9.193431ms (current)
Screenshot profile : 9.730317ms (smooth) | 7.233225ms (current)
Screenshot profile : 9.923961ms (smooth) | 11.666759ms (current)
Screenshot profile : 10.171064ms (smooth) | 12.395005ms (current)
Screenshot profile : 10.436771ms (smooth) | 12.828136ms (current)
Screenshot profile : 10.752213ms (smooth) | 13.591184ms (current)
Screenshot profile : 10.677605ms (smooth) | 10.006127ms (current)
Screenshot profile : 10.696332ms (smooth) | 10.864876ms (current)
Screenshot profile : 10.836714ms (smooth) | 12.100148ms (current)
Screenshot profile : 10.384002ms (smooth) | 6.309598ms (current)
Screenshot profile : 10.512785ms (smooth) | 11.671834ms (current)
Screenshot profile : 10.594671ms (smooth) | 11.331652ms (current)
Screenshot profile : 11.022106ms (smooth) | 14.869019ms (current)
Screenshot profile : 11.056261ms (smooth) | 11.363660ms (current)
Screenshot profile : 13.173499ms (smooth) | 32.228638ms (current)
Screenshot profile : 12.901811ms (smooth) | 10.456617ms (current)
Screenshot profile : 12.511471ms (smooth) | 8.998418ms (current)
Screenshot profile : 60.684856ms (smooth) | 494.245331ms (current)
Screenshot profile : 111.287766ms (smooth) | 566.713928ms (current)
Screenshot profile : 118.577721ms (smooth) | 184.187302ms (current)
Screenshot profile : 126.834038ms (smooth) | 201.140869ms (current)
Screenshot profile : 233.015961ms (smooth) | 1188.653198ms (current)
Screenshot profile : 293.934875ms (smooth) | 842.205017ms (current)
Screenshot profile : 282.354095ms (smooth) | 178.127045ms (current)
Screenshot profile : 297.604187ms (smooth) | 434.854919ms (current)
Screenshot profile : 300.026642ms (smooth) | 321.828796ms (current)
Screenshot profile : 298.798157ms (smooth) | 287.741913ms (current)
Screenshot profile : 307.527008ms (smooth) | 386.086761ms (current)
Screenshot profile : 294.194061ms (smooth) | 174.197708ms (current)
Screenshot profile : 286.482117ms (smooth) | 217.074570ms (current)
Screenshot profile : 277.750549ms (smooth) | 199.166428ms (current)
Screenshot profile : 271.708069ms (smooth) | 217.325623ms (current)
Screenshot profile : 245.042664ms (smooth) | 5.053972ms (current)
Screenshot profile : 221.163406ms (smooth) | 6.250124ms (current)
Screenshot profile : 208.384155ms (smooth) | 93.371033ms (current)
Screenshot profile : 207.589813ms (smooth) | 200.440811ms (current)
Screenshot profile : 223.785492ms (smooth) | 369.546631ms (current)
Screenshot profile : 221.480774ms (smooth) | 200.738419ms (current)
Screenshot profile : 230.090012ms (smooth) | 307.573181ms (current)
Screenshot profile : 254.507935ms (smooth) | 474.269287ms (current)
Screenshot profile : 283.468353ms (smooth) | 544.112122ms (current)
Screenshot profile : 285.878754ms (smooth) | 307.572601ms (current)
Screenshot profile : 300.691986ms (smooth) | 434.011261ms (current)
Screenshot profile : 301.684082ms (smooth) | 310.613220ms (current)
Screenshot profile : 272.227661ms (smooth) | 7.119990ms (current)
Screenshot profile : 246.098129ms (smooth) | 10.932533ms (current)
Screenshot profile : 281.438873ms (smooth) | 599.505737ms (current)
Screenshot profile : 291.068756ms (smooth) | 377.737671ms (current)
Screenshot profile : 262.161163ms (smooth) | 1.992869ms (current)
Screenshot profile : 236.614410ms (smooth) | 6.693653ms (current)
Screenshot profile : 243.460983ms (smooth) | 305.080231ms (current)
Screenshot profile : 240.609909ms (smooth) | 214.950256ms (current)
Screenshot profile : 266.002258ms (smooth) | 494.533417ms (current)
Screenshot profile : 276.689453ms (smooth) | 372.874268ms (current)
Screenshot profile : 278.445312ms (smooth) | 294.248047ms (current)
Screenshot profile : 268.703094ms (smooth) | 181.023148ms (current)
Screenshot profile : 242.027161ms (smooth) | 1.943824ms (current)
Screenshot profile : 218.654465ms (smooth) | 8.300381ms (current)
Screenshot profile : 211.597733ms (smooth) | 148.087173ms (current)
Screenshot profile : 191.547241ms (smooth) | 11.092879ms (current)
Screenshot profile : 181.838150ms (smooth) | 94.456367ms (current)
Screenshot profile : 164.788208ms (smooth) | 11.338873ms (current)
Screenshot profile : 151.486023ms (smooth) | 31.766415ms (current)
Screenshot profile : 159.313858ms (smooth) | 229.764404ms (current)
Screenshot profile : 220.536041ms (smooth) | 771.535706ms (current)
Screenshot profile : 198.653290ms (smooth) | 1.708489ms (current)
Screenshot profile : 180.131805ms (smooth) | 13.438550ms (current)
Screenshot profile : 307.717621ms (smooth) | 1455.989990ms (current)
Screenshot profile : 477.049713ms (smooth) | 2001.038452ms (current)
Screenshot profile : 434.271057ms (smooth) | 49.263458ms (current)
Screenshot profile : 392.732391ms (smooth) | 18.884504ms (current)
Screenshot profile : 396.588654ms (smooth) | 431.295227ms (current)
Screenshot profile : 410.529907ms (smooth) | 536.001404ms (current)
Screenshot profile : 420.648346ms (smooth) | 511.714478ms (current)
Screenshot profile : 421.814819ms (smooth) | 432.313385ms (current)
Screenshot profile : 398.381866ms (smooth) | 187.485214ms (current)
Screenshot profile : 359.150482ms (smooth) | 6.068115ms (current)
Screenshot profile : 395.477631ms (smooth) | 722.422058ms (current)
Screenshot profile : 356.116364ms (smooth) | 1.864945ms (current)
Screenshot profile : 321.195648ms (smooth) | 6.909203ms (current)
Screenshot profile : 313.617981ms (smooth) | 245.419037ms (current)
Screenshot profile : 291.778534ms (smooth) | 95.223839ms (current)
Screenshot profile : 275.232025ms (smooth) | 126.313583ms (current)
Screenshot profile : 299.395660ms (smooth) | 516.868530ms (current)
Screenshot profile : 289.037140ms (smooth) | 195.810669ms (current)
Screenshot profile : 472.922241ms (smooth) | 2127.887939ms (current)
Screenshot profile : 425.895874ms (smooth) | 2.658584ms (current)
Screenshot profile : 404.271606ms (smooth) | 209.653427ms (current)
编辑:下载 profile results
最佳答案
CGWindow API 不适用于高帧率捕获。一方面,它没有捕获当前显示的屏幕图像。它被概括为可能捕获内容的各个部分。它可以包含或排除窗口、桌面元素、阴影等。这意味着它会为每次调用合成一个新图像。是的,这意味着它必须锁定所有窗口的后备缓冲区。
Apple 提供了一对关于捕获屏幕内容的技术问答文章。一种用于捕获单张图像,他们建议使用 CGDisplayCreateImage()
。 .另一个是随着时间的推移捕捉屏幕事件的电影,他们推荐使用 AV Foundation。 Technical Q&A QA1741: How to take an image snapshot of the screen on Mac OS X Lion Technical Q&A QA1740: How to capture screen activity to a movie file using AV Foundation on Mac OS X Lion
关于objective-c - OSX 上的屏幕捕获代码缓慢。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19287179/
我尝试理解[c代码 -> 汇编]代码 void node::Check( data & _data1, vector& _data2) { -> push ebp -> mov ebp,esp ->
我需要在当前表单(代码)的上下文中运行文本文件中的代码。其中一项要求是让代码创建新控件并将其添加到当前窗体。 例如,在Form1.cs中: using System.Windows.Forms; ..
我有此 C++ 代码并将其转换为 C# (.net Framework 4) 代码。有没有人给我一些关于 malloc、free 和 sprintf 方法的提示? int monate = ee; d
我的网络服务器代码有问题 #include #include #include #include #include #include #include int
给定以下 html 代码,将列表中的第三个元素(即“美丽”一词)以斜体显示的 CSS 代码是什么?当然,我可以给这个元素一个 id 或一个 class,但 html 代码必须保持不变。谢谢
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 7 年前。
我试图制作一个宏来避免重复代码和注释。 我试过这个: #define GrowOnPage(any Page, any Component) Component.Width := Page.Surfa
我正在尝试将我的旧 C++ 代码“翻译”成头条新闻所暗示的 C# 代码。问题是我是 C# 中的新手,并不是所有的东西都像 C++ 中那样。在 C++ 中这些解决方案运行良好,但在 C# 中只是不能。我
在 Windows 10 上工作,R 语言的格式化程序似乎没有在 Visual Studio Code 中完成它的工作。我试过R support for Visual Studio Code和 R-T
我正在处理一些报告(计数),我必须获取不同参数的计数。非常简单但乏味。 一个参数的示例查询: qCountsEmployee = ( "select count(*) from %s wher
最近几天我尝试从 d00m 调试网络错误。我开始用尽想法/线索,我希望其他 SO 用户拥有可能有用的宝贵经验。我希望能够提供所有相关信息,但我个人无法控制服务器环境。 整个事情始于用户注意到我们应用程
我有一个 app.js 文件,其中包含如下 dojo amd 模式代码: require(["dojo/dom", ..], function(dom){ dom.byId('someId').i
我对“-gencode”语句中的“code=sm_X”选项有点困惑。 一个例子:NVCC 编译器选项有什么作用 -gencode arch=compute_13,code=sm_13 嵌入库中? 只有
我为我的表格使用 X-editable 框架。 但是我有一些问题。 $(document).ready(function() { $('.access').editable({
我一直在通过本教程学习 flask/python http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-i-hello-wo
我想将 Vim 和 EMACS 用于 CNC、G 代码和 M 代码。 Vim 或 EMACS 是否有任何语法或模式来处理这种类型的代码? 最佳答案 一些快速搜索使我找到了 this vim 和 thi
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 想改进这个问题?更新问题,使其成为 on-topic对于堆栈溢出。 7年前关闭。 Improve this
这个问题在这里已经有了答案: Enabling markdown highlighting in Vim (5 个回答) 6年前关闭。 当我在 Vim 中编辑包含 Markdown 代码的 READM
我正在 Swift3 iOS 中开发视频应用程序。基本上我必须将视频 Assets 和音频与淡入淡出效果合并为一个并将其保存到 iPhone 画廊。为此,我使用以下方法: private func d
pipeline { agent any stages { stage('Build') { steps { e
我是一名优秀的程序员,十分优秀!