clock_t clock()歧义 [英] clock_t clock() ambiguity

查看:90
本文介绍了clock_t clock()歧义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

clock_t clock()是否测量实时或处理时间?除非我错过了某些东西,否则Stroustrup在TC ++ PL(第D.4.4.1节)中的处理是

在这个问题上不太清楚。 />

为主要编译器g ++,VC ++和

Macintosh编译器和其他C ++编译器(Linux / Unix,Windows和
MacOS?

Does clock_t clock() measure real time or process time? Unless I have
missed something, Stroustrup''s treatment in TC++PL (section D.4.4.1) is
none too clear on that question.

Is clock() well-implemented for the major compilers g++, VC++, and
Macintosh compilers and other C++ compilers on Linux/Unix, Windows, and
MacOS?

推荐答案

Matt写道:
Matt wrote:

是不是clock_t clock()测量实时或处理时间?除非我错过了某些东西,否则Stroustrup在TC ++ PL(第D.4.4.1节)中的处理是

在这个问题上不太清楚。 />

为主要编译器g ++,VC ++和

Macintosh编译器和其他C ++编译器(Linux / Unix,Windows和
MacOS?
Does clock_t clock() measure real time or process time? Unless I have
missed something, Stroustrup''s treatment in TC++PL (section D.4.4.1) is
none too clear on that question.

Is clock() well-implemented for the major compilers g++, VC++, and
Macintosh compilers and other C++ compilers on Linux/Unix, Windows, and
MacOS?

http://msdn.microsoft.com/library/de..._crt_clock.asp


标准的代码。所有值得使用的编译器都会有它。


然后注意第一行是计算

调用过程使用的挂钟时间。那个挂钟是指挂钟。是实时的行话,而不是处理

时间。并且由呼叫过程使用 时代是指时代。

计划开始时开始。


将来,请在发布之前向Google提出问题!我通过[msdn clock_t]的第一次引用回答了你所有的问题。


-

Phlip
http://c2.com/cgi/wiki?ZeekLand < - - 不是博客!!!

http://msdn.microsoft.com/library/de..._crt_clock.asp

Note the compatibility is "ANSI", which is MS''s code for the "ISO C
Standard". All compilers worth using will have it.

Then note the first line is "Calculates the wall-clock time used by the
calling process." That "wall-clock" is jargon for real time, not process
time. And "used by the calling process" means the "epoch" starts when the
program starts.

In future, please hit a question with Google before posting it! I answered
all your questions with the first citation for [msdn clock_t].

--
Phlip
http://c2.com/cgi/wiki?ZeekLand <-- NOT a blog!!!


Matt写道:
Matt wrote:

clock_t clock()是实时测量还是处理时间?除非我错过了某些东西,否则Stroustrup在TC ++ PL(第D.4.4.1节)中的处理是

在这个问题上不太清楚。
Does clock_t clock() measure real time or process time? Unless I have
missed something, Stroustrup''s treatment in TC++PL (section D.4.4.1) is
none too clear on that question.



IIRC,它不是由C或C ++标准定义的。这两种语言都没有实时与处理时间的固有概念,因此实现

会因平台而异。

IIRC, it''s not defined by the C or C++ standards. Neither language has
the inherent concept of real time vs. process time, so implementations
will vary from platform to platform.


时钟()适用于主要编译器g ++,VC ++和

Macintosh编译器和Linux / Unix,Windows上的其他C ++编译器和

MacOS?
Is clock() well-implemented for the major compilers g++, VC++, and
Macintosh compilers and other C++ compilers on Linux/Unix, Windows, and
MacOS?



取决于您所说的良好实施。该功能是标准所要求的
,是的,但是它的功能是否相同

到处都是?没有。


干杯! --M

Depends on what you mean by "well-implemented." The function is
required by the standard, yes, but does it function the same
everywhere? No.

Cheers! --M


Matt写道:
Matt wrote:

clock_t clock()是否实时测量或处理时间?除非我错过了某些东西,否则Stroustrup在TC ++ PL(第D.4.4.1节)中的处理是

在这个问题上不太清楚。
Does clock_t clock() measure real time or process time? Unless I have
missed something, Stroustrup''s treatment in TC++PL (section D.4.4.1) is
none too clear on that question.



C ++从标准C头time.h继承clock()。 C标准的公开

可用草案说:


7.23.2.1时钟功能


概要

1 #include< time.h>

clock_t clock(void);


描述

2时钟功能决定使用的处理器时间。


返回

3时钟功能返回实现的最佳近似值

自从开始实现定义时代以来程序使用的处理器时间仅与程序调用有关。要确定以秒为单位的时间,时钟函数

返回的值应除以宏CLOCKS_PER_SEC的值。如果使用的

处理器时间不可用或其值无法表示,则函数返回值(clock_t)-1。

C++ inherits clock() from the standard C header time.h. The publicly
available draft of the C standard says:

7.23.2.1 The clock function

Synopsis
1 #include <time.h>
clock_t clock(void);

Description
2 The clock function determines the processor time used.

Returns
3 The clock function returns the implementation?s best approximation to the
processor time used by the program since the beginning of an
implementation-defined era related only to the program invocation. To
determine the time in seconds, the value returned by the clock function
should be divided by the value of the macro CLOCKS_PER_SEC. If the
processor time used is not available or its value cannot be represented,
the function returns the value (clock_t)-1.


为主要编译器g ++,VC ++和

Macintosh编译器和Linux / Unix,Windows上的其他C ++编译器提供了良好的实现。

MacOS?
Is clock() well-implemented for the major compilers g++, VC++, and
Macintosh compilers and other C++ compilers on Linux/Unix, Windows, and
MacOS?



我不知道,我认为这不是该组的热门话题。

Best

Kai-Uwe Bux

I don''t know, and I think it is not topical in this group.
Best

Kai-Uwe Bux


这篇关于clock_t clock()歧义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆