发表机构
University of Waterloo(滑铁卢大学)
机构由 AI 辅助整理,请以论文原文为准。AI 中文总结
本研究揭示 Scratch 虚拟机中循环速度受重绘门影响的不确定性,提出 ThrottleCheck 工具实现预算语义,并量化其对游戏和测试的影响,建议评分器模拟门机制。
AI 中文摘要
Scratch 拥有 1.35 亿注册用户,其中大多数是儿童,以及 1.64 亿个共享项目。关于脚本速度,他们被教导的内容仅用一句话概括:循环每帧迭代一次。不幸的是,这句话描述的是例外情况。在公共虚拟机中,一帧会重复执行脚本,直到有可见内容请求屏幕重绘、没有脚本在运行,或者帧的墙钟时间已用掉四分之三。因此,不进行绘制的循环的速度由其他可见内容和机器决定。隐藏一个包含两个精灵的项目中移动的精灵,另一个精灵的计数循环在笔记本电脑上的运行速度会快 77,000 倍。没有任何文档说明这一规则。我们的关键观察是,重绘门是整个运行时的一个标志,因此循环的速度可以在不修改其代码的情况下改变:隐藏绘制的精灵、改变机器的预算,或在没有渲染器的工具中运行程序。ThrottleCheck 在未修改的虚拟机上实现了预算语义(每帧轮数的明确预算,模拟重绘门),在每个旋钮下运行项目,并报告对速率敏感的项目及其见证。在 500 个流行的公共游戏中,59% 包含一个从不绘制且从不等待的循环。静音绘制精灵的请求会在十秒后改变 24% 的包含此类精灵的游戏的状态;隐藏它们会改变 18%;在没有渲染器和没有门的情况下运行游戏会改变 61%。在固定时间后读取位置、分数或时钟的规则,在节流阀释放后,在 Whisker 自身的示例测试中有 17% 以及在其 224 个混改版的教程检查中有 19% 会从通过变为失败。没有渲染器的评分器会评分编辑器从未运行的程序,除非它模拟门并声明预算;我们说明了评分器和平台应该做什么,并以一句可以教给儿童的话作为结尾。
英文摘要
Scratch has 135 million registered users, most of them children, and 164 million shared projects. What they are taught about the speed of a script fits in one sentence: a loop iterates once per frame. Unfortunately, that sentence describes the exception. In the public virtual machine a frame repeats the scripts until something visible asks the screen to redraw, no script is left running, or three quarters of the frame's wall-clock time are spent. Hence a loop that does not draw is paced by whatever else is visible and by the machine. Hide the moving sprite of a two-sprite project, and the other's counting loop runs 77,000 times faster on a laptop. No documentation states the rule. Our key observation is that the redraw gate is one flag for the whole runtime, so a loop's speed can be changed without touching its code: hide the sprite that draws, change the machine's budget, or run the program in a tool with no renderer. ThrottleCheck implements a budgeted semantics (a stated budget of rounds per frame, the redraw gate emulated) on the unmodified virtual machine, runs a project under each knob, and reports a rate-sensitive project with a witness. On 500 popular public games, 59% contain a loop that never draws and never waits. Muting the requests of the sprites that draw changes the state of a played game after ten seconds in 24% of the games that have one; hiding them changes 18%; running the game without a renderer and without the gate changes 61%. Rules that read a position, a score or a clock after a fixed time reverse between pass and fail once the throttle is released, in 17% of Whisker's own example tests and 19% of a tutorial's checks on 224 of its remixes. A grader without a renderer grades a program the editor never runs, unless it emulates the gate and states a budget; we say what graders and the platform should do, and close with the sentence a child could be taught.