我正在尝试修复git-svn中的间歇性错误.问题出现在Windows XP中,包括Cygwin git(perl v5.10.1)和msysGit(perl v5.8.8).
对于涉及获取的任何操作,我能够中途进行操作,然后操作就会消失,类似于
无法打开.git/svn/refs/remotes/trunk/.rev_map.cc05479a-e8ea-436f-8d71-e07493b7796c.lock:设备或资源繁忙
在/ usr/lib/git-core/git-svn第5240行
但是,确切的锁定文件和行号并不总是相同.我已将实际问题跟踪到3679行
sysopen(my $fh, $db_lock, O_RDWR | O_CREAT)
Run Code Online (Sandbox Code Playgroud)
这是创建一个新的.lock文件,我试过相当于无效.
open(my $fh, ">", $db_lock)
Run Code Online (Sandbox Code Playgroud)
我检查了目录的权限,它是drwxr-xr-x,所以不应该有任何问题,或者如果它们是,它们就不会那么不一致.
这可能是因为脚本正在快速连续多次创建和重命名这个文件,XP无法处理它?编辑:我怀疑是这种情况,因为当我使用perl调试器并手动启动每个sysopen的执行时,我提取的100个修订版本没有问题.
编辑:一些Git开发人员更愿意找出根本原因,而不是发生工作的黑客(我认为正确的方法).那么,任何人都可以帮我找到否认我允许打开这些.lock文件的罪魁祸首吗?我有许多理论上可以用于此目的的工具,但它们并不完全是这样的:
简而言之,有没有什么方法可以在不成为微软员工的情况下获得更多信息?
编辑2:它可能不是赛门铁克,而是我们在联网计算机上运行的另一个程序.我有一些人在研究它,他们应该能够至少缩小原因.
我的应用程序中有一个计时错误,只有在我使用valgrind时才会发生,因为valgrind会减慢这个过程.
(它实际上是一个boost :: weak_ptr-exception,我无法本地化)
现在我想知道如何用gdb重现bug.我没有看到组合gdb + valgrind的方法.
谢谢.
我需要在很长一段时间(几个小时)内每隔几毫秒(20,30,40毫秒)获得准确的时间戳.采用时间戳的函数作为第三方库的回调调用.
使用GetSystemTime()一个可以得到正确的系统时间戳,但只有毫秒精度,这对我来说不够精确.使用会QueryPerformanceTimer()产生更准确的时间戳,但与系统时间戳长期不同步(请参阅http://msdn.microsoft.com/en-us/magazine/cc163996.aspx).
上面链接的站点提供的解决方案只能在旧计算机上运行,当我尝试与较新的计算机一起使用时,它会在同步时挂起.
在我看来,提升也只是在毫秒精度上工作.如果可能的话,我想避免使用外部库,但如果没有其他选择,我会继续使用它.
有什么建议?
谢谢.
对此有点困惑.如果我加快处理器的速度,那么执行任务会不会花费更少的时间,从而导致更快地完成截止日期?
谢谢
我在64位Ubuntu 12.04系统上并尝试以下代码:
#include <unistd.h>
#include <time.h>
#include <stdio.h>
int
main(void)
{
struct timespec user1,user2;
struct timespec sys1,sys2;
double user_elapsed;
double sys_elapsed;
clock_gettime(CLOCK_REALTIME, &user1);
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &sys1);
sleep(10);
clock_gettime(CLOCK_REALTIME, &user2);
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &sys2);
user_elapsed = user2.tv_sec + user2.tv_nsec/1E9;
user_elapsed -= user1.tv_sec + user1.tv_nsec/1E9;
printf("CLOCK_REALTIME: %f\n", user_elapsed);
sys_elapsed = sys2.tv_sec + sys2.tv_nsec/1E9;
sys_elapsed -= sys1.tv_sec + sys1.tv_nsec/1E9;
printf("CLOCK_PROCESS_CPUTIME_ID: %f\n", sys_elapsed);
}
Run Code Online (Sandbox Code Playgroud)
据我了解,这应该打印出类似的东西
CLOCK_REALTIME: 10.000117
CLOCK_PROCESS_CPUTIME_ID: 10.001
Run Code Online (Sandbox Code Playgroud)
但就我而言,我得到的是
CLOCK_REALTIME: 10.000117
CLOCK_PROCESS_CPUTIME_ID: 0.000032
Run Code Online (Sandbox Code Playgroud)
这是正确的行为吗?如果是这样,我如何确定sys1和sys2的实际秒数?
当我将CLOCK_PROCESS_CPUTIME_ID更改为CLOCK_REALTIME然后我得到了预期的结果,但这不是我想要的,因为我们需要精度.
[编辑]显然CLOCK_PROCESS_CPUTIME_ID返回cpu在prcessing上花费的实际时间.CLOCK_MONOTONIC似乎返回正确的值.但是精确度如何呢?
所以我试图用std :: chrono :: high_resolution_clock来计时执行某件事需要多长时间。我认为您可以找到开始时间和结束时间之间的区别...
为了检查我的方法是否有效,我编写了以下程序:
#include <iostream>
#include <chrono>
#include <vector>
void long_function();
int main()
{
std::chrono::high_resolution_clock timer;
auto start_time = timer.now();
long_function();
auto end_time = timer.now();
auto diff_millis = std::chrono::duration_cast<std::chrono::duration<int, std::milli>>(end_time - start_time);
std::cout << "It took " << diff_millis.count() << "ms" << std::endl;
return 0;
}
void long_function()
{
//Should take a while to execute.
//This is calculating the first 100 million
//fib numbers and storing them in a vector.
//Well, it doesn't actually, because it
//overflows …Run Code Online (Sandbox Code Playgroud) 我已经浏览了这个网站.从这里我得到了使用cudamallocHost的固定内存提供了比cudamalloc更好的性能.然后我使用两个不同的简单程序并测试执行时间为
使用cudaMallocHost
#include <stdio.h>
#include <cuda.h>
// Kernel that executes on the CUDA device
__global__ void square_array(float *a, int N)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx<N) a[idx] = a[idx] * a[idx];
}
// main routine that executes on the host
int main(void)
{
clock_t start;
start=clock();/* Line 8 */
clock_t finish;
float *a_h, *a_d; // Pointer to host & device arrays
const int N = 100000; // Number of elements in arrays
size_t …Run Code Online (Sandbox Code Playgroud) 所以我有这个代码
function timer()
{
setTimeout(function(){alert("Out of time")}, 3000); //Alerts "Out of time" after 3000 milliseconds
}
function resetTime()
{
timer(); //this is not right, i thought it would override the first function but it just adds another timer as well which is not what I want
}
function stopTime()
{
//What could go here to stop the first function from fully executing before it hits 3000 milliseconds and displays the alert message?
}
Run Code Online (Sandbox Code Playgroud)
函数timer()在页面加载时启动但是如果我有一个stopTime()按钮并且我点击它,我如何停止执行第一个函数并阻止它达到3000毫秒标记并提醒"超时" "?
这可能是一个愚蠢/明显的问题,但只是想确保我的预感是正确的.
我正在使用time.perf_counter()在Python3脚本中执行一些基本的性能计时,如下所示:
start = time.perf_counter()
# some time consuming operation here
end = time.perf_counter()
elapsed = end - start
Run Code Online (Sandbox Code Playgroud)
我会得到像9.774或36.903这样的值(当然还有更多的小数位).我假设数字越大=时间越长,但这些数字到底意味着什么呢?例如,1.23小秒仅1秒和0.23分秒
timing ×10
c++ ×2
time ×2
windows ×2
benchmarking ×1
c ×1
c++-chrono ×1
c++11 ×1
clock ×1
copying ×1
cuda ×1
debugging ×1
embedded ×1
exception ×1
gdb ×1
gettime ×1
git ×1
git-svn ×1
html ×1
javascript ×1
optimization ×1
perl ×1
php ×1
precision ×1
python ×1
python-3.x ×1
real-time ×1
timer ×1
timestamp ×1
valgrind ×1