commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gilles (JIRA)" <>
Subject [jira] [Commented] (LANG-1373) Stopwatch based capability for nested, named, timings in a call stack
Date Sat, 24 Feb 2018 16:41:00 GMT


Gilles commented on LANG-1373:

{quote}I have addressed the feedback with one exception
{quote}one exception, I kept the node package private
I'd generally avoid that if possible (it's so easy that someone will wonder again and make
it public...): Can't it be indirectly tested (so that coverage should be OK)?
{quote}Also, path is back, but we just create and pass as part of visitation.
I ran the example given in the Javadoc, but it doesn't seem to work as expected if I try
public void outerFunction() {
    try {
        StackWatch<String,String> watch = new StackWatch<>("OuterFunction");
        functionTwo(watch); // <-- Appends to "functionOne" paths.
        watch.visit(new StackWatch.TimingVisitor<String,String>() {
                public void visitTiming(int level, List<String> path,  StackWatch.Timing<String,String>
timing) {
                    System.out.println("Visit level " + level + " timing: " + timing.getName()
+ " path: " + path);
    } catch (Exception e) {}
Side note: The above corrects a typo in the Javadoc. Also the \{@literal} tag is fairly annoying
(for reading/copying and for checking that the example works ;)), better inclose the whole
block in [{@code ...}|].

> Stopwatch based capability for nested, named, timings in a call stack
> ---------------------------------------------------------------------
>                 Key: LANG-1373
>                 URL:
>             Project: Commons Lang
>          Issue Type: New Feature
>          Components: lang.time.*
>            Reporter: Otto Fowler
>            Assignee: Otto Fowler
>            Priority: Major
>         Attachments: LANG-1373.patch
> While working on adding some timing functionality to a Metron feature, I came across
> Stopwatch class, but found that it didn’t suite my needs.
> What I wanted to do was to create a timing from a top level function in our Stellar dsl,
and have have a group of related timings, such that the end result was the overall time of
the call, and nested timings of other calls executed during the dsl execution of that function.
These timings would all be named, and have a path for identification and include timing the
language compiler/execution as well as the function execution itself. It would be helpful
if they were tagged in some way as well, such that the consumer could filter during visitation.
> So I have written StackWatch to provide this functionality, and submitted it in a Metron
> From the PR description:
> StackWatch
> A set of utility classes under the new package stellar.common.timing have been added.
These provide the StackWatch functionality.
> StackWatch provides an abstraction over the Apache Commons StopWatch class that allows
callers to create multiple named and possibly nested timing operations.
> <…>
> This class may be more generally useful to this and other projects, but I am not sure
where it would live since we wouldn’t want it in common.
> StackWatch uses a combination of Deque and a custom Tree implementation to create, start
and end timing operations.
> A Visitor pattern is also implemented to allow for retrieving the results after the completion
of the operation.

This message was sent by Atlassian JIRA

View raw message