Skip to content

Commit

Permalink
add perf
Browse files Browse the repository at this point in the history
  • Loading branch information
sarulabs committed Jul 10, 2024
1 parent 4380bba commit 1225542
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -689,3 +689,22 @@ func handler(w http.ResponseWriter, r *http.Request, ctn di.Container) {
# Performance

TODO:

Retrieving an object from a container will always be slower than directly using a variable. That being said, DI tries to minimize the cost of using containers.

## Get parameter

The `Get` method accepts different types as parameter. If possible you should use a `di.Def`...

## Shared objects

- First call, need to create the object. Slower. Need to lock the container to store the object.
- Next calls are very fast.

## Unshared object

- Fast if no close function (close function requires to store the object in the container, lock the container)

## deep nesting


0 comments on commit 1225542

Please sign in to comment.