- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在寻找在数据集中花费的总时间
我的数据集可能如下所示:
(第一次建议后更新数据集)
起始时间
结束时间
44224,32869
44224,33603
44224,30975
44224,33616
44224,30965
44224,32824
44223,34859
44223,46875
44223,41349
44223,44875
这将给我 9000 - 4000,50 - 500 的总时间(从没有时间在 5000 和 5500 之间工作)= 4499,5
找到最小开始时间和最大结束时间给了我这个集合的范围,如果下一个开始时间大于上一个结束时间(例如在 5000 到 6000 中,减去 1000),我可以从中减去数据。但是,从最后一个数据点来看,这 1000 个减去的时间单位中有 500 个已用于总时间。有什么简单的方法可以从这样的数据集中找到总花费的时间吗?在 VBA Excel 中编程。谢谢你的时间!
当前使用此代码:
For i = 7 to lastRow
If timeEnd(i) < timeStart(i - 1) Then
subtractTime = subtractTime + (timeStart(i - 1) - timeEnd(i))
End If
If timeStart(i) < firstTime Then
firstTime = timeStart(i)
End If
If timeEnd(i) > lastTime Then
lastTime = timeEnd(i)
End If
totalTimeSpent(i) = lastTime - firstTime - subtractTime
Next i
找到了一个适用于我的数据集的解决方案:首先对数据进行排序,使其按顺序排列,然后运行上面的代码。
最佳答案
这是很长的路要走,它将时间从最低到最高循环,并在考虑时进行计数:
Function mytime(stRng As Range, edRng As Range)
Dim stArr() As Variant
stArr = Intersect(stRng.Parent.UsedRange, stRng).Value
Dim edArr() As Variant
edArr = Intersect(edRng.Parent.UsedRange, edRng).Value
If UBound(stArr, 1) <> UBound(edArr, 1) Then Exit Function
Dim cnt As Long
cnt = 0
For i = Application.Min(stArr) To Application.Max(edArr)
For j = 1 To UBound(stArr, 1)
If i >= stArr(j, 1) And i < edArr(j, 1) Then
cnt = cnt + 1
Exit For
End If
Next j
Next i
mytime = cnt
End Function
关于excel - 查找在连续数据中花费的时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66693871/
我一直在读一本分配给类(class)的书,它提到数组访问需要 O(1) 时间。我意识到这非常快(也许尽可能快),但是如果您有一个循环必须多次引用它,那么分配一个临时变量以在数组中查找值有什么好处吗?或
我一直试图找出为什么这个查询花了这么长时间。以前,它的执行时间约为 150 毫秒到 200 毫秒,但现在需要 25 秒或更长时间。这是从昨晚到今天之间的事。唯一改变的就是将数据添加到表中。 根据下面的
我有一个 ng repeat 重复数据。 - data.image(src)部分为null,src=null的不再重复。 我用一个简单的 ng-if 解决了它。
我有一个包含大量测试的 Laravel 项目。我正在使用 pcov 来计算代码覆盖率,大约需要 4 分钟。但是 pcov 不支持分支覆盖,所以我决定使用 xdebug。 使用 xdebug 测试执行,
我已经被这个问题困扰了一段时间了,我被难住了。 Automapper 需要 4 秒来映射 19 个对象。在我的机器(24GB 内存,3.6Ghz i7)上,该操作应该花费毫秒或纳秒。 这是映射调用。
我有一个包含大量测试的 Laravel 项目。我正在使用 pcov 来计算代码覆盖率,大约需要 4 分钟。但是 pcov 不支持分支覆盖,所以我决定使用 xdebug。 使用 xdebug 测试执行,
我在机器 A 上有一个 java 进程通过 TCP 与机器 B 上的 Tomcat 通信。 TCP 连接(只是 syn-syn/ack 交换)始终需要 100 毫秒的数量级,而 ping 请求需要 1
我做了一项任务,从 sqlserver 获取超过 200 万条记录并将它们填充到 Asp.net GridView 中。 问题是,查询需要超过 2 分钟才能获得记录,而我的查询现在已经完全优化。 当我
我希望将 165 秒变成 2:40 而不是 0:2:45 函数需要能够适应秒值的大小。 我知道有无数种方法可以做到这一点,但我正在寻找一种干净的方法来做到这一点,除了 jQuery 之外没有任何外部库
我是一名优秀的程序员,十分优秀!