フィルターのクリア

Why is datenummx(clock) faster than now()?

3 ビュー (過去 30 日間)
Dan Couture
Dan Couture 2013 年 1 月 2 日
Why is running datenummx(clock) 4x faster than the standard now() call? https://gist.github.com/4432190

採用された回答

per isakson
per isakson 2013 年 1 月 2 日
編集済み: per isakson 2013 年 1 月 2 日
The function, now, has one executable line of code
t = datenum(clock);
the function, datenum, calls the function, datenummx, after having done error checking, etc.
That's why.
  2 件のコメント
Dan Couture
Dan Couture 2013 年 1 月 3 日
Thanks per isakson.
I did see the layers of function calls below now() which is where I dug out the datenummx(clock) code. My question was intended to focus on why does matlab have all those layers in between that just slow it down? My apologies for the vagueness of the originial question.
  • Why does Matlab not alias now() directly to datenummx(clock)?
  • There is no user input, so error checking should be minimal (if any)
and as a follow-up:
  • Is there something still below the datenummx call that would be even faster?
I am running a fairly complex simulation through object oriented m-files and need to reference the current system time quickly and continually.
per isakson
per isakson 2013 年 1 月 3 日
編集済み: per isakson 2013 年 1 月 3 日
I often find it difficult to understand the rational behind various design decisions of The MathWorks (TMW). Since, TMW is successful in the money-making industry, I guess TMW knows what they are doing.
Regarding datenummx I guess it is possible to make a faster function (little error checking, one OS (Windows only), maybe "in-place".) Post a new question.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeHolidays / Seasons についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by