Skip to content

Commit

Permalink
api: add helpers to wrap lambdas with a timer (#1087)
Browse files Browse the repository at this point in the history
Adds helpers to the Timer interface to wrap the common
lambda types in `java.util.function`. This can be useful
to wrap a lambda that is passed to another class in order
to measure each invocation. For example:

```java
Timer t = registry.timer(id);
int sum = Arrays
    .stream(new String[] {"foo", "bar", "baz"})
    .mapToInt(t.wrapToIntFunction(String::length))
    .sum();
```

Caller should ensure that the lambda does sufficient
work that timing an invocatino will not be more costly
than executing the lambda body.
  • Loading branch information
brharrington authored Oct 25, 2023
1 parent 4a6e64d commit 5e44940
Show file tree
Hide file tree
Showing 2 changed files with 1,143 additions and 4 deletions.
Loading

0 comments on commit 5e44940

Please sign in to comment.