2009年(33)
分类: C/C++
2009-06-19 22:11:34
|
命令是TIMEFORMAT="" time ./test < ~/tmp/bochs-2.4.tar.gz
bochs-2.4.tar.gz文件总共3.9MB,(环境是vmware, red hat linux 9)
用fgets(s, 1024, stdin)时:
0.00user 0.01system 0:00.01elapsed 90%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (74major+12minor)pagefaults 0swaps
用fgets(s, 2, stdin)时:
0.37user 0.00system 0:00.39elapsed 94%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (74major+12minor)pagefaults 0swaps
用scanf("%1024s", s)时:
0.08user 0.00system 0:00.10elapsed 73%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (79major+12minor)pagefaults 0swaps
用scanf("%2s", s)时:
0.29user 0.02system 0:00.32elapsed 96%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (79major+12minor)pagefaults 0swaps
用ch = getchar()时:
0.13user 0.04system 0:00.18elapsed 91%CPU (0avgtext+0avgdata 0maxresident)k
0inputs+0outputs (72major+12minor)pagefaults 0swaps