什么是实施“尾巴”的最佳方式? [英] What is best way to implement "tail"?
问题描述
实现tail -f的最佳方法是什么?在c或C ++及更高版本中,与unix shell命令tail -f相比,
的性能或perl
文件::尾巴?任何建议表示赞赏。谢谢。
Owen Zhang< ow *************** @gmail。 comwrites:
实现tail -f的最佳方法是什么?在c或C ++及更高版本中,与unix shell命令tail -f相比,
的性能或perl
文件::尾巴?任何建议表示赞赏。谢谢。
你用这些
实现观察到了哪些性能问题?
-
Ben Pfaff
http://benpfaff.org
在2007-09-19 19:41,Owen Zhang写道:
实现tail -f的最佳方法是什么? ;在c或C ++及更高版本中,与unix shell命令tail -f相比,
的性能或perl
文件::尾巴?任何建议表示赞赏。谢谢。
您需要使用特定于平台的功能来执行此操作,请在
小组中讨论您平台上的编程问题。
-
Erik Wikstr ?? m
9月19日下午2:11,Erik Wikstr? m< Erik-wikst ... @ telia.comwrote:
2007-09-19 19:41,Owen Zhang写道:
实现tail -f的最佳方法是什么?在c或C ++及更高版本中,与unix shell命令tail -f相比,
的性能或perl
文件::尾巴?任何建议表示赞赏。谢谢。
您需要使用特定于平台的功能来执行此操作,请在
组中询问您的平台上的编程。
废话。可以在ISO
标准C中完成(无视效率问题)。
#include< stdio.h>
#include< stdlib.h>
#include< time.h>
void WaitFiveSecs(void)
{
clock_t现在,稍后;
now = clock();
do
稍后= clock();
while(((稍后 - 现在)/ CLOCKS_PER_SEC)< 5);
}
int main(void)
{
int datum;
for(;;)
{
if((datum = getchar())!= EOF)
putchar(datum);
else WaitFiveSecs();
}
返回EXIT_SUCCESS;
}
-
Erik Wikstr?m
What is the best way to implement "tail -f" in C or C++ and higher
performance compared to either unix shell command "tail -f" or perl
File::Tail ? Any suggestion appreciated. Thanks.
Owen Zhang <ow***************@gmail.comwrites:
What is the best way to implement "tail -f" in C or C++ and higher
performance compared to either unix shell command "tail -f" or perl
File::Tail ? Any suggestion appreciated. Thanks.What performance problems have you observed with these
implementations?
--
Ben Pfaff
http://benpfaff.org
On 2007-09-19 19:41, Owen Zhang wrote:What is the best way to implement "tail -f" in C or C++ and higher
performance compared to either unix shell command "tail -f" or perl
File::Tail ? Any suggestion appreciated. Thanks.You would need to use platform specific functions to do that, ask in a
group discussing programming on your platform.
--
Erik Wikstr??m
On Sep 19, 2:11 pm, Erik Wikstr?m <Erik-wikst...@telia.comwrote:On 2007-09-19 19:41, Owen Zhang wrote:
What is the best way to implement "tail -f" in C or C++ and higher
performance compared to either unix shell command "tail -f" or perl
File::Tail ? Any suggestion appreciated. Thanks.
You would need to use platform specific functions to do that, ask in a
group discussing programming on your platform.Nonsense. It can be done (disregarding questions of efficiency) in ISO
standard C.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void WaitFiveSecs(void)
{
clock_t now, later;
now = clock();
do
later = clock();
while (((later-now)/CLOCKS_PER_SEC) < 5);
}
int main(void)
{
int datum;
for(;;)
{
if ((datum = getchar()) != EOF)
putchar(datum);
else WaitFiveSecs();
}
return EXIT_SUCCESS;
}
--
Erik Wikstr?m
这篇关于什么是实施“尾巴”的最佳方式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!