You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As a result, iteration through the vector must be done with for loops, and ruby-isms cannot be used. If enumerable was included, this would allow each, all?, map, select, <<, ect. to be used, which is the expected and default behavior for iteration over array-type data-structures in ruby. The current workaround is to cast the OS Vector to a string, and then eval it. This is obviously very sub-optimal.
The text was updated successfully, but these errors were encountered:
One good piece of news - I tested the performance of casting vs looping, and (I assume) thanks to the staticly linked binaries, the speed of looping is really good now. I'll replace the random OS Vector with one from a sql file and confirm, but it looks like this is just a interface issue.
require'openstudio'require'benchmark'# Make an array of random 1min ts dataos_vec=OpenStudio::Vector.new(525600)values=Array.new(525600){rand() * 5000}foriin1..525599os_vec[i]=values[i]endBenchmark.bm(1)do |x|
x.report("cast:"){# cast the vector to a string and then cast it to an array of stringsquick_proc=os_vec.to_s.split(',')# the first and last have some cleanup items because of the Vector methodquick_proc[0]=quick_proc[0].gsub(/^.*\(/,'')quick_proc[-1]=quick_proc[-1].gsub(")",'')# convert each of the values to a floatquick_proc.map!{ |val| val.to_f}}x.report("loop:"){# loop through each value to retrieve itslow_proc=[]foriin1..os_vec.length - 1slow_proc << os_vec[i]end}end
with the result
user system total real
cast: 0.350000 0.020000 0.370000 ( 0.383714)
loop: 0.070000 0.000000 0.070000 ( 0.074864)
As a result, iteration through the vector must be done with for loops, and ruby-isms cannot be used. If enumerable was included, this would allow each, all?, map, select, <<, ect. to be used, which is the expected and default behavior for iteration over array-type data-structures in ruby. The current workaround is to cast the OS Vector to a string, and then eval it. This is obviously very sub-optimal.
The text was updated successfully, but these errors were encountered: