- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在使用 Microbenchmark
时,我注意到第一次执行总是比其余的慢很多。这种效果在不同的机器和不同的功能上是相同的。这是否与图书馆有关,或者这是某种预热?
library(microbenchmark)
X <- matrix(rnorm(100), nrow = 10)
microbenchmark(solve(X))$time
#[1] 82700 23700 18300 17700 19700 19100 16900 17500 17300 16600 16700 16700 18500 16900 17700 16900 17000 16200 17400 17000 16800 16600 17000 16700 16800 17100
#[27] 17300 17100 16800 17800 17400 18100 17400 18100 18000 16700 17400 17300 17000 16800 16400 17300 16700 16900 16900 16700 17200 17800 16600 17100 16800 17800
#[53] 17000 17200 17500 17200 17200 17300 17800 17600 17600 17200 16600 16700 16800 16600 16400 16500 17300 17600 16800 17600 16300 16800 17100 16500 16800 16700
#[79] 16300 16700 16300 16700 16800 16700 16400 17100 16400 17100 17000 18000 16600 16600 16600 16800 16700 16500 17600 19100 17400 16900
最佳答案
与预热时间有关,参见help('microbenchmark')
,section details,参数控制:
The control list can contain the following entries:
order
[omited]warmup
the number of warm-up iterations performed before the actual benchmark. These are used to estimate the timing overhead as well as spinning up the processor from any sleep or idle states it might be in. The default value is 2.
如果您增加预热迭代次数,第一次运行可能不是最慢的,尽管很多时候是最慢的。
library(microbenchmark)
set.seed(2020)
X <- matrix(rnorm(100), nrow = 10)
times <- microbenchmark(solve(X), control = list(warmup = 10))$time
times
# [1] 145229 72724 65333 65305 115715 63797 689113 72101 64830 66392
# [11] 65776 66619 65531 64765 65351 65605 65745 65106 64661 65790
# [21] 65435 64964 66138 65952 66893 65654 65585 75141 74666 69060
# [31] 72725 66650 65486 65894 66808 65381 66039 65959 64842 65029
# [41] 65673 66439 64394 70585 68899 73875 73180 67807 65891 65699
# [51] 64693 63679 65504 80190 66150 65048 64372 64842 65845 65144
# [61] 65543 65297 65485 64695 66580 64921 65453 64840 65559 65805
# [71] 64362 66098 65464 65227 64998 64007 65659 63919 64727 64796
# [81] 65231 64030 65871 65735 64217 65195 65181 65130 66015 63891
# [91] 63755 65274 65116 64573 64244 64214 64148 64457 65346 64228
现在看看哪个是第一个 order
:
order(times, decreasing = TRUE)
# [1] 7 1 5 54 28 29 46 47 31 2 8 44 30 45 48 25 35 32 12
# [20] 65 42 10 55 23 72 37 89 38 24 34 49 83 59 70 20 11 17 84
# [39] 50 41 77 26 16 27 69 61 13 53 33 63 73 67 21 36 15 99 3
# [58] 4 62 92 81 74 86 87 60 88 93 18 56 40 75 22 66 39 58 68
# [77] 9 80 14 79 64 51 19 94 98 43 57 71 95 100 85 96 97 82 76
# [96] 78 90 6 91 52
在这种情况下,最慢的是第七次运行,而不是第一次。
关于r - 为什么第一次运行微基准测试总是最慢的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64106124/
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 9 年前。 Improve th
使用微 Controller 时,通常您必须对寄存器进行写入和读取,为了使代码更具可读性,您需要定义寄存器地址及其位。这有点好,但是当您的寄存器名称彼此非常相似时,它很快就会变得困惑,例如此处所示 #
微 Controller 背景下的“原子操作”是什么? 我正在研究 TI F28027 MCU。 The data sheet says that its operations are atomic
我正在用 PIC 微 Controller 做一个项目。我有一个 ADC 采样并将数据保存到 RAM 存储器,一旦 RAM 被填满,我需要使用 PIC 微 Controller 通过蓝牙发送它。 我的
如何确定微 Controller 中特定程序所需的堆栈内存? 例如,假设我有一个内部可能有许多子例程或线程的程序。在我开始执行程序之前,我想修复这个程序的堆栈大小。我如何标记堆栈的终点。 最佳答案 我
我知道 printf 和 sprintf 之间的基本功能差异。但是,我想知道它们之间一些与时间/延迟相关的差异。显然,我想在我的一个自定义构建 RTOS 的任务中使用它。你怎么看 ?我想知道更多它会如
关闭。这个问题需要多问focused 。目前不接受答案。 想要改进此问题吗?更新问题,使其仅关注一个问题 editing this post . 已关闭 9 年前。 Improve this ques
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 我们不允许提问寻求书籍、工具、软件库等的推荐。您可以编辑问题,以便用事实和引用来回答。 关闭 5 年前。
我有一个一般性的问题。我在微 Controller 上记录错误。但是微 Controller 的资源比 Windows 计算机更有限。在我的例子中,我将 64 个错误代码保存在一个队列中,由 Free
关闭。此题需要details or clarity 。目前不接受答案。 想要改进这个问题吗?通过 editing this post 添加详细信息并澄清问题. 已关闭 6 年前。 Improve th
假设我有一个时钟速度为 20 Mhz 的 8 位定时器。计时器在多少时间内可以计数多远而不溢出。或者1秒内溢出多少次?我知道它可以数到 255 并且会溢出 最佳答案 时间和频率之间的关系是t = 1/
我正在开展一个全面的长期 C 编程项目,该项目需要模块化编程方法。作为设计的一部分,将创建库,因此我想确认头文件组织的正确/错误解释: 问题 假设您正在创建一个库。经过深思熟虑,您决定您希望构想的最终
1. #define timers ((dual_timers *)0x03FF6000) 这是 ARM 微 Controller 中使用的内存映射定义 结构定义在哪里 2. struct dua
我购买了 LinkSprite JPEG 彩色相机和 LPC1768 mbed 微 Controller 。通过“LinkSprite”相机,我可以拍摄 jpeg 格式的图像,根据他们提供的教程,我可
我有很多不同的时间来跟踪我的设计,但没有什么是 super 关键的。 10 毫秒 +/- 几毫秒根本不是什么大问题。但是可能有 10 个不同的定时器同时在不同的周期进行计数,显然我没有足够的专用定时器
是否可以通过串行端口与 PIC 单片机通信 Android 应用程序?我可以使用哪些低成本手机?对不起,我是哥伦比亚人。 最佳答案 不确定 PIC,但是 Arduino可能是一个很好的引用点,并且有一
今天我一直在思考以下问题: 在一台普通的 pc 中,当你分配一些内存时,你向操作系统请求它,它会跟踪哪些内存段被占用,哪些内存段没有被占用,并且不要让你弄乱其他程序的内存等。但是微 Controlle
我已经为微 Controller 的键盘开发了一个 c 驱动程序。我想改变它,例如,当我按下 1 时,它会显示 1,直到我按下另一个数字。截至目前,数字只有在我按下数字时才会改变,这意味着一旦我松开键
我有一个在线程之间共享的 volatile unsigned char array LedState[5] 变量。数组中的每个索引表示一个状态。根据每个状态,LED 将以不同的顺序闪烁。一个线程设置数
我有一个项目要对微 Controller PIC18F 进行编程,我必须将一个开关电路连接到微 Controller 板上,这个开关电路有一个电锁和一个蜂鸣器要连接到它。 锁最初是通电的。假设当我发送
我是一名优秀的程序员,十分优秀!