speedtst.cpp
来自「精工打印头LTP3445的使用范例。有原理图和源码」· C++ 代码 · 共 21 行
CPP
21 行
#include <dos.h>
#include <time.h>
#include <stdio.h>
void main(void)
{
static unsigned long first, second;
printf("\nThe program calculates time interval to perform 10 million of writes to 0x378\nTakes about 20 seconds. Please wait...\n");
first = *(long*)MK_FP(0x40, 0x6c); /* Gets system
time */
for(unsigned long i=0;i<10000000L;i++)
outportb(0x378, i&0xff);
second = *(long*)MK_FP(0x40, 0x6c); /* Gets system time
again */
static int in = second-first;
static float f = (second-first)/18.2;
printf("10 million of writes to 0x378 took %d timer ticks (%5.3f seconds)\n",in, f);
printf("About %5.3f us per write\n", f/10.);
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?