Is the performance of comparing datetime datatypes slower than datenum
조회 수: 8 (최근 30일)
이전 댓글 표시
I'm finding where a desired timestamp (`datetime`) fits within a large datetime array. However, this step takes a very long time and from the profiler, it appears most of the time is spent on datevec. Would it be faster to convert everything over to datenum values?
Currently the comparison step looks like this:
tol = duration(0,0,0,40);
time = datetime(timeIn);
idx = arrayfun(@(x) find(abs(x.time-time)<=tol),obj,'uni',0);
댓글 수: 1
dpb
2016년 7월 15일
What's the form of timeIn? What may help is to give the specific format; at one time (I believe/maybe still does?) datenum looked at each element if a format wasn't provided which was much slower than with the appropriate format.
I'd not be terribly surprised if as a rule datetime is somewhat slower than datenum simply because it's more capable as well as the object stuff will add some overhead as well, in all likelihood.
I can't test the comparative here, though...
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!