-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new evaluate() overload to Model
Until now when users evaluate a Model, the Model internally creates the Image object that will hold the result, and then returns it to the user. This way, each time a new evaluation happens, a new Image object is created, then eventually destroyed. Although for small images this doesn't cause too much of an overhead, for bigger images where allocation times are noticeable this can become one of the driving costs (e.g., a 10k x 10k Image object takes ~350 ms to be created). To help take that cost down, and allow users reuse allocated memory/Images, this commit adds a new evaluate() overload that takes in an Image reference rather than returning one. The given image is checked, and if its size is exactly that needed by the Model internal evaluation routines then it is simply zero'd out and then used for drawing pixels on. If on the other hand the image's size is not exactly that needed by the Model, a new one is created with the required dimensions and used instead. With these changes, the existing evaluate() overload becomes a thin wrapper around the new one, creating an empty Image object, passing it to the new overload, then returning it to the user. Signed-off-by: Rodrigo Tobar <[email protected]>
- Loading branch information
Showing
3 changed files
with
33 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters