hive icon indicating copy to clipboard operation
hive copied to clipboard

Update add/modify/remove sim methods to use safe version

Open nreinicke opened this issue 3 years ago • 3 comments

PR #95 adds in new safe methods for adding/modifying/removing hive entities from the simulation state. Now, we need to go through and update the usage of the old methods to use these new safe methods internally.

For example, in https://github.com/NREL/hive/blob/19f07ead124fa1cc518ef3c04ca9314ccfd1e41c/hive/state/vehicle_state/dispatch_trip.py#L78 we could update this to use the safe method modify_request_safe().

nreinicke avatar Aug 22 '22 21:08 nreinicke

i'd like to couple with this a performance benchmark, to make sure the overhead of switching to ResultE is insignificant.

edit: and yes i would also like this!

robfitzgerald avatar Aug 23 '22 16:08 robfitzgerald

i'd like to couple with this a performance benchmark, to make sure the overhead of switching to ResultE is insignificant.

yes, that's a great point; this would be great to have but not if it comes at a high performance cost.

nreinicke avatar Aug 25 '22 17:08 nreinicke

I just did a quick test of this, comparing a method that returns the old ErrorOr type to a function that returns the ResultE type (and unwraps the result). The performance cost for this is ~1 microsecond. This seems like an okay tradeoff in performance relative to what we gain in ergonomics.

nreinicke avatar Aug 25 '22 17:08 nreinicke