NREL / OpenStudio-workflow-gem

http://openstudio.net
Other
14 stars 4 forks source link

Improve speed (REXML) #105

Closed shorowit closed 4 years ago

shorowit commented 4 years ago

Currently require 'rexml/document' is called during invocation; it takes ~0.75 seconds on Windows and ~0.5 seconds on Linux. But REXML is only used in one very specific situation when there are report files. Therefore, we can move the require statement into the report code block and lazy load REXML.

shorowit commented 4 years ago

I ran tests locally on Windows Subsystem for Linux (WSL) with the existing CLI using: openstudio -I OpenStudio-workflow-gem/lib/ -e "t = Time.now; load 'openstudio-workflow.rb'; puts \"#{Time.now - t}\""

Original: 1.1 sec Modified: 0.6 sec

Windows should show even larger improvements.

shorowit commented 4 years ago

Would love to get this into OS v3.

jmarrec commented 4 years ago

As long as tests pass I'm ok with it. I wonder why it's so slow and whether a lightweight replacement exists, but that's just curiosity.

Good find anyways!

jmarrec commented 4 years ago

Actually I think we are (trying?) Embedding nokogiri native which could be a replacement candidate, and faster at parsing at least

shorowit commented 4 years ago

Yep, nokogiri would help address this.

Similarly, loading the json_pure gem is also a performance hotspot. Embedding the C json gem would address that. JSON parsing occurs throughout the gem so there's no easy way to lazy load like I could do here.

nllong commented 4 years ago

The json_pure gem is being removed in OpenStudio 3. So that should help too.