CFThread "ElapsedTime" continues to go up after thread has finished executing.

Description

The ElapsedTime metadata property on a CFThread has different behavior in Lucee vs. Adobe ColdFusion. In ACF, the ElapsedTime property is a snapshot of how long the thread took to execute. In Lucee, however, the value continues to increase even after the thread as completed execution.

ACF: ElapsedTime = ( EndTime - StartTime )

Lucee: ElapsedTime = ( Now() - StartTime )

I demonstrated the difference here: https://www.bennadel.com/blog/4121-cfthread-elapsedtime-is-not-processor-time-in-lucee-cfml-5-3-8-201.htm

To reproduce, all you have to do is start a few threads with some sleep() commands and then dump out the cfthread scope when they have joined - the ElapsedTime values will basically all be the same (within a few ms).

Activity

Show:

Zac Spitzer 18 July 2022 at 10:11

Pothys - MitrahSoft 18 July 2022 at 10:06

I’ve improved the testcase PR:

Zac Spitzer 18 July 2022 at 08:45

this is causing builds to fail intermittently

Zac Spitzer 7 July 2022 at 09:47

Pothys - MitrahSoft 7 July 2022 at 08:29

I added a fix to this ticket

With this fix,

  • thread ElapsedTime will be calculated by thread endTime - startTime instead of now() - startTime.

  • For running threads, ElapsedTime will be calculated by now() - startTime.

  • For terminated threads, ElapsedTime always returns 0 as ACF does.

Pull Request:

Fixed

Details

Assignee

Reporter

New Issue warning screen

Before you create a new Issue, please post to the mailing list first https://dev.lucee.org

Once the issue has been verified, one of the Lucee team will ask you to file an issue

Sprint

Fix versions

Priority

Created 23 September 2021 at 14:52
Updated 3 August 2022 at 11:21
Resolved 7 July 2022 at 14:08