f("test strcpy"));
}
PerformanceTestLog(TEST_LOG_INF, "test strcmp");
for (i = 0; i < nTimes; ++i)
{
if (0 == strcmp(tmp, "test strcpy"))
{
i = i;
}
}
PerformanceTestLog(TEST_LOG_INF, "test memcmp");
for (i = 0; i < nTimes; ++i)
{
if (0 == memcmp(tmp, "test strcpy", sizeof("test strcpy")))
{
i = i;
}
}
PerformanceTestLog(TEST_LOG_INF, "test strcpy1");
for (i = 0; i < nTimes; ++i)
{
strcpy(tmp, "test strcpy test strcpy test strcpy test strcpy test strcpytest strcpy");
}
PerformanceTestLog(TEST_LOG_INF, "test memcpy1");
for (i = 0; i < nTimes; ++i)
{
memcpy(tmp, "test strcpy test strcpy test strcpy test strcpy test strcpytest strcpy",
sizeof("test strcpy test strcpy test strcpy test strcpy test strcpytest strcpy"));
}
PerformanceTestLog(TEST_LOG_INF, "test strcmp1");
for (i = 0; i < nTimes; ++i)
{
if (0 == strcmp(tmp, "test strcpy test strcpy test strcpy test strcpy test strcpytest strcpy"))
{
i = i;
}
}
PerformanceTestLog(TEST_LOG_INF, "test memcmp1");
for (i = 0; i < nTimes; ++i)
{
if (0 == memcmp(tmp, "test strcpy test strcpy test strcpy test strcpy test strcpytest strcpy",
sizeof("test strcpy test strcpy test strcpy test strcpy test strcpytest strcpy")))
{
i = i;
}
}
stopTimer(TEST_LOG_INF, 0);
nTimes /= 5; //8千万
WriteLog(LOG_KEY, "BaseTest %lu", nTimes);
PerformanceTestLog(TEST_LOG_INF, "test sprintf");
for (i = 0; i < nTimes; ++i)
{
sprintf(tmp, "thiis %s testing %d", "sprintf", i);
}
PerformanceTestLog(TEST_LOG_INF, "test sscanf");
for (i = 0; i < nTimes; ++i)
{
sscanf(tmp, "%s %s %s %d", t1, t2, t3, &nTmp);
}
{
FILE *fp;
int nStr;
PerformanceTestLog(TEST_LOG_INF, "fopen");
fp = fopen("performancetest.txt", "w");
strWriten = "this is testing write\n";
nStr = strlen(strWriten);
PerformanceTestLog(TEST_LOG_INF, "test write file");
for (i = 0; i < nTimes; ++i)
{
fwrite(strWriten, 1, nStr, fp);
}
PerformanceTestLog(TEST_LOG_INF, "fflush");
fflush(fp);
PerformanceTestLog(TEST_LOG_INF, "test fprintf file");
for (i = 0; i < nTimes; ++i)
{
//太过简单的fprintf好像会被自动优化成fwrite,即使没开优化选项
//例如 fprintf(fp, "%s", "strWriten");
fprintf(fp, "%s %d\n", "strWriten", i);
}
PerformanceTestLog(TEST_LOG_INF, "fclose");
fclose(fp);
}
{
FILE *fp;
int nStr;
PerformanceTestLog(TEST_LOG_INF, "fopen 1");
fp = fopen("performancetest.txt", "r");
nStr = strlen(strWriten);
PerformanceTestLog(TEST_LOG_INF, "test read file");
for (i = 0; i < nTimes; ++i)
{
fread(tmp, 1, nStr, fp);
tmp[nStr] = '\0';
}
PerformanceTestLog(TEST_LOG_INF, "test fscanf file");
tmp[0] = t1[0] = '\0';
for (i = 0; i < nTimes; ++i)
{
fscanf(fp, "%s %s", tmp, t1);
}
PerformanceTestLog(TEST_LOG_INF, "fclose");
fclose(fp);
}
fclose(fopen("performancetest.txt", "w"));
nTime |