From 3582f038e5cbdb0483429a7385883c1937a704fb Mon Sep 17 00:00:00 2001
From: AB
Date: Tue, 16 Apr 2024 08:39:05 +0200
Subject: [PATCH 01/27] Rename I
---
{standard-maven-template => hierarchical-in-code-profile}/pom.xml | 0
.../pom.xml | 0
2 files changed, 0 insertions(+), 0 deletions(-)
rename {standard-maven-template => hierarchical-in-code-profile}/pom.xml (100%)
rename {standard-maven-template-demo => hierarchical-in-code-profiler-demo}/pom.xml (100%)
diff --git a/standard-maven-template/pom.xml b/hierarchical-in-code-profile/pom.xml
similarity index 100%
rename from standard-maven-template/pom.xml
rename to hierarchical-in-code-profile/pom.xml
diff --git a/standard-maven-template-demo/pom.xml b/hierarchical-in-code-profiler-demo/pom.xml
similarity index 100%
rename from standard-maven-template-demo/pom.xml
rename to hierarchical-in-code-profiler-demo/pom.xml
From ff5049bec5287baf388453f7ffae3c965234d318 Mon Sep 17 00:00:00 2001
From: AB
Date: Tue, 16 Apr 2024 08:41:25 +0200
Subject: [PATCH 02/27] Rename II
---
.run/Run Demo.run.xml | 2 +-
CONTRIBUTING.md | 4 ++--
README.md | 12 ++++++------
SECURITY.md | 2 +-
hierarchical-in-code-profile/pom.xml | 12 ++++++------
hierarchical-in-code-profiler-demo/pom.xml | 4 ++--
pom.xml | 6 +++---
7 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/.run/Run Demo.run.xml b/.run/Run Demo.run.xml
index 764b3b9..5eaa97e 100644
--- a/.run/Run Demo.run.xml
+++ b/.run/Run Demo.run.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index cbb31c6..8d92d3a 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -33,10 +33,10 @@ You should have the following things installed:
* Ensure that the JDK/Java-Version is correct
-## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/standard-maven-template/release.yml?branch=master)](https://github.com/xdev-software/standard-maven-template/actions/workflows/release.yml)
+## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/hierarchical-in-code-profiler/release.yml?branch=master)](https://github.com/xdev-software/hierarchical-in-code-profiler/actions/workflows/release.yml)
Before releasing:
-* Consider doing a [test-deployment](https://github.com/xdev-software/standard-maven-template/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
+* Consider doing a [test-deployment](https://github.com/xdev-software/hierarchical-in-code-profiler/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
* Check the [changelog](CHANGELOG.md)
If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes
diff --git a/README.md b/README.md
index db9412b..2fe180a 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,12 @@
-[![Latest version](https://img.shields.io/maven-central/v/software.xdev/standard-maven-template?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/standard-maven-template)
-[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/standard-maven-template/checkBuild.yml?branch=develop)](https://github.com/xdev-software/standard-maven-template/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
-[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_standard-maven-template&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_standard-maven-template)
+[![Latest version](https://img.shields.io/maven-central/v/software.xdev/hierarchical-in-code-profiler?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/hierarchical-in-code-profiler)
+[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/hierarchical-in-code-profiler/checkBuild.yml?branch=develop)](https://github.com/xdev-software/hierarchical-in-code-profiler/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
+[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_hierarchical-in-code-profiler&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_hierarchical-in-code-profiler)
-# standard-maven-template
+# hierarchical-in-code-profiler
## Installation
-[Installation guide for the latest release](https://github.com/xdev-software/standard-maven-template/releases/latest#Installation)
+[Installation guide for the latest release](https://github.com/xdev-software/hierarchical-in-code-profiler/releases/latest#Installation)
## Support
@@ -16,4 +16,4 @@ If you need support as soon as possible and you can't wait for any pull request,
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.
## Dependencies and Licenses
-View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/standard-maven-template/dependencies)
+View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/hierarchical-in-code-profiler/dependencies)
diff --git a/SECURITY.md b/SECURITY.md
index 92188f3..d2752c4 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -2,4 +2,4 @@
## Reporting a Vulnerability
-Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/standard-maven-template/security/advisories/new).
+Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/hierarchical-in-code-profiler/security/advisories/new).
diff --git a/hierarchical-in-code-profile/pom.xml b/hierarchical-in-code-profile/pom.xml
index f25578a..158e753 100644
--- a/hierarchical-in-code-profile/pom.xml
+++ b/hierarchical-in-code-profile/pom.xml
@@ -5,17 +5,17 @@
4.0.0
software.xdev
- standard-maven-template
+ hierarchical-in-code-profiler
1.0.0-SNAPSHOT
jar
- standard-maven-template
- standard-maven-template
- https://github.com/xdev-software/standard-maven-template
+ hierarchical-in-code-profiler
+ hierarchical-in-code-profiler
+ https://github.com/xdev-software/hierarchical-in-code-profiler
- https://github.com/xdev-software/standard-maven-template
- scm:git:https://github.com/xdev-software/standard-maven-template.git
+ https://github.com/xdev-software/hierarchical-in-code-profiler
+ scm:git:https://github.com/xdev-software/hierarchical-in-code-profiler.git
2023
diff --git a/hierarchical-in-code-profiler-demo/pom.xml b/hierarchical-in-code-profiler-demo/pom.xml
index 0a4432d..d812cdc 100644
--- a/hierarchical-in-code-profiler-demo/pom.xml
+++ b/hierarchical-in-code-profiler-demo/pom.xml
@@ -5,7 +5,7 @@
4.0.0
software.xdev
- standard-maven-template-demo
+ hierarchical-in-code-profiler-demo
1.0.0-SNAPSHOT
jar
@@ -29,7 +29,7 @@
software.xdev
- standard-maven-template
+ hierarchical-in-code-profiler
${project.version}
diff --git a/pom.xml b/pom.xml
index 4e48f7a..8e94148 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
software.xdev
- standard-maven-template-root
+ hierarchical-in-code-profiler-root
1.0.0-SNAPSHOT
pom
@@ -15,8 +15,8 @@
- standard-maven-template
- standard-maven-template-demo
+ hierarchical-in-code-profiler
+ hierarchical-in-code-profiler-demo
From 553f2fcaa0b8e8b514db18be588573a6059f71f5 Mon Sep 17 00:00:00 2001
From: AB
Date: Tue, 16 Apr 2024 08:42:51 +0200
Subject: [PATCH 03/27] Rename III
---
.../pom.xml | 0
1 file changed, 0 insertions(+), 0 deletions(-)
rename {hierarchical-in-code-profile => hierarchical-in-code-profiler}/pom.xml (100%)
diff --git a/hierarchical-in-code-profile/pom.xml b/hierarchical-in-code-profiler/pom.xml
similarity index 100%
rename from hierarchical-in-code-profile/pom.xml
rename to hierarchical-in-code-profiler/pom.xml
From 0b82e2b0ccb2e244085295250131e4cce33c420a Mon Sep 17 00:00:00 2001
From: AB
Date: Tue, 16 Apr 2024 09:06:48 +0200
Subject: [PATCH 04/27] Add code
---
.../main/java/software/xdev/Application.java | 72 ++++
hierarchical-in-code-profiler/pom.xml | 10 +-
.../xdev/profiling/InCodeLogProfiler.java | 70 ++++
.../xdev/profiling/InCodeProfiler.java | 365 ++++++++++++++++++
.../profiling/InCodeProfilerAutoClosable.java | 52 +++
5 files changed, 568 insertions(+), 1 deletion(-)
create mode 100644 hierarchical-in-code-profiler-demo/src/main/java/software/xdev/Application.java
create mode 100644 hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeLogProfiler.java
create mode 100644 hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfiler.java
create mode 100644 hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfilerAutoClosable.java
diff --git a/hierarchical-in-code-profiler-demo/src/main/java/software/xdev/Application.java b/hierarchical-in-code-profiler-demo/src/main/java/software/xdev/Application.java
new file mode 100644
index 0000000..6125036
--- /dev/null
+++ b/hierarchical-in-code-profiler-demo/src/main/java/software/xdev/Application.java
@@ -0,0 +1,72 @@
+package software.xdev;
+
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.stream.IntStream;
+
+import software.xdev.profiling.InCodeLogProfiler;
+import software.xdev.profiling.InCodeProfilerAutoClosable;
+
+
+public final class Application
+{
+ public static void main(final String[] args)
+ {
+ try(final InCodeLogProfiler profiler = InCodeLogProfiler.createStarted(
+ "Run dummy",
+ System.out::println, // Could also be LOGGER::debug
+ true)) // Could also be LOGGER.isDebugEnabled()
+ {
+ final List> completableFutures;
+ try(final InCodeProfilerAutoClosable ignored = profiler.nestedAC("Launch tasks"))
+ {
+ completableFutures = IntStream.of(1, 2, 3)
+ .mapToObj(i -> CompletableFuture.runAsync(() -> {
+ try(final InCodeProfilerAutoClosable process = profiler.nestedAC("Process " + i, true))
+ {
+ try(final InCodeProfilerAutoClosable ignore = process.nestedAC("Fetch"))
+ {
+ sleep(5);
+ }
+
+ try(final InCodeProfilerAutoClosable ignore = process.nestedAC("Process"))
+ {
+ sleep(i * 5);
+ }
+
+ if(i % 2 == 0)
+ {
+ try(final InCodeProfilerAutoClosable ignore = process.nestedAC("Finalize"))
+ {
+ sleep(5);
+ }
+ }
+ }
+ }))
+ .toList();
+ }
+
+ try(final InCodeProfilerAutoClosable ignored = profiler.nestedAC("Wait for tasks"))
+ {
+ completableFutures.forEach(CompletableFuture::join);
+ }
+ }
+ }
+
+ private static void sleep(final int ms)
+ {
+ try
+ {
+ Thread.sleep(ms);
+ }
+ catch(final InterruptedException iex)
+ {
+ throw new RuntimeException("Interrupted");
+ // Thread.currentThread().interrupt();
+ }
+ }
+
+ private Application()
+ {
+ }
+}
diff --git a/hierarchical-in-code-profiler/pom.xml b/hierarchical-in-code-profiler/pom.xml
index 158e753..d45acb6 100644
--- a/hierarchical-in-code-profiler/pom.xml
+++ b/hierarchical-in-code-profiler/pom.xml
@@ -18,7 +18,7 @@
scm:git:https://github.com/xdev-software/hierarchical-in-code-profiler.git
- 2023
+ 2024
XDEV Software
@@ -84,6 +84,14 @@
+
+
+ org.apache.commons
+ commons-lang3
+ 3.14.0
+
+
+
diff --git a/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeLogProfiler.java b/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeLogProfiler.java
new file mode 100644
index 0000000..9378ea3
--- /dev/null
+++ b/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeLogProfiler.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package software.xdev.profiling;
+
+import java.util.function.Consumer;
+
+
+/**
+ * Same as {@link InCodeProfilerAutoClosable} but with a Consumer that handles
+ * {@link InCodeProfiler#getPrettyPrinted()}
+ *
+ * @see InCodeProfilerAutoClosable
+ */
+public class InCodeLogProfiler extends InCodeProfilerAutoClosable
+{
+ protected final Consumer logConsumer;
+
+ public InCodeLogProfiler(
+ final String taskName,
+ final Consumer logConsumer,
+ final boolean async,
+ final boolean enabled)
+ {
+ super(taskName, async, enabled);
+ this.logConsumer = logConsumer;
+ }
+
+ @Override
+ public void close()
+ {
+ super.close();
+ this.stopAll();
+ if(this.isEnabled())
+ {
+ this.logConsumer.accept(this.getPrettyPrinted());
+ }
+ }
+
+ public static InCodeLogProfiler createStarted(
+ final String taskName,
+ final Consumer logConsumer,
+ final boolean async,
+ final boolean enabled)
+ {
+ final InCodeLogProfiler sw = new InCodeLogProfiler(taskName, logConsumer, async, enabled);
+ sw.start();
+ return sw;
+ }
+
+ public static InCodeLogProfiler createStarted(
+ final String taskname,
+ final Consumer logConsumer,
+ final boolean enabled)
+ {
+ return createStarted(taskname, logConsumer, false, enabled);
+ }
+}
diff --git a/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfiler.java b/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfiler.java
new file mode 100644
index 0000000..49b9d99
--- /dev/null
+++ b/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfiler.java
@@ -0,0 +1,365 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package software.xdev.profiling;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.stream.Collectors;
+
+import org.apache.commons.lang3.time.StopWatch;
+
+
+/**
+ * Presents a hierarchical Profiler based on StopWatches
+ *
+ * Example:
+ *
+ * {@code
+ * 100,00% 100,00% - getIssueInfos[keys=[X-1000]] [391ms]
+ * 0,11% 0,11% - Check cache [0ms]
+ * 98,78% 98,78% - Get results of async processes [386ms]
+ * ASYNC ASYNC - Process issue[key=X-1000] async [386ms]
+ * 98,70% 100,00% - getIssueInfoByKeyInternal[key=X-1000] [386ms]
+ * 98,66% 99,96% - Fetch data [386ms]
+ * 98,22% 99,55% - getIssueByKey[key=X-1000] [384ms]
+ * 0,44% 0,45% ? unspecified [2ms]
+ * 0,03% 0,03% - Wait for hierarchy-asyncs [0ms]
+ * 0,00% 0,00% ? unspecified [0ms]
+ * 0,00% 0,00% ? unspecified [0ms]
+ * 0,38% 0,38% - Put cache [2ms]
+ * 0,73% 0,73% ? unspecified [3ms]
+ * }
+ *
+ *
+ */
+public class InCodeProfiler
+{
+ protected static final double NANOS_TO_MILLIS_FACTOR = 1000000.0;
+
+ protected final String taskName;
+ protected final boolean async;
+ protected final boolean enabled;
+
+ protected final StopWatch sw = new StopWatch();
+
+ protected final List nestedProfilers = Collections.synchronizedList(new ArrayList<>());
+
+ public InCodeProfiler(final String taskName, final boolean async, final boolean enabled)
+ {
+ super();
+
+ this.taskName = Objects.requireNonNull(taskName);
+ this.async = async;
+ this.enabled = enabled;
+ }
+
+ public InCodeProfiler(final String taskName, final boolean async)
+ {
+ this(taskName, async, true);
+ }
+
+ public InCodeProfiler(final String taskName)
+ {
+ this(taskName, false);
+ }
+
+ protected String gettaskName()
+ {
+ return this.taskName;
+ }
+
+ public StopWatch getStopWatch()
+ {
+ return this.sw;
+ }
+
+ protected boolean isEnabled()
+ {
+ return this.enabled;
+ }
+
+ protected boolean isAsync()
+ {
+ return this.async;
+ }
+
+ protected boolean isNotAsync()
+ {
+ return !this.isAsync();
+ }
+
+ public void start()
+ {
+ if(!this.isEnabled())
+ {
+ return;
+ }
+ this.sw.start();
+ }
+
+ public void stop()
+ {
+ if(!this.sw.isStopped())
+ {
+ this.sw.stop();
+ }
+ }
+
+ /**
+ * Tries to stop all nested profilers
+ */
+ public void stopAll()
+ {
+ this.stop();
+ for(final InCodeProfiler hsw : this.nestedProfilers)
+ {
+ hsw.stopAll();
+ }
+ }
+
+ protected void addNested(final InCodeProfiler nested, final boolean start)
+ {
+ if(!this.isEnabled())
+ {
+ return;
+ }
+
+ this.nestedProfilers.add(nested);
+
+ if(start)
+ {
+ nested.start();
+ }
+ }
+
+ /**
+ * Creates a new nested profiler
+ */
+ public InCodeProfiler nested(final String taskName, final boolean async)
+ {
+ final InCodeProfiler nested = new InCodeProfiler(taskName, async, this.isEnabled());
+
+ this.addNested(nested, true);
+
+ return nested;
+ }
+
+ /**
+ * Creates a new nested profiler
+ */
+ public InCodeProfiler nested(final String taskName)
+ {
+ return this.nested(taskName, false);
+ }
+
+ /**
+ * Creates a new nested {@link AutoCloseable} profiler
+ */
+ public InCodeProfilerAutoClosable nestedAC(final String taskName, final boolean async)
+ {
+ final InCodeProfilerAutoClosable nested = new InCodeProfilerAutoClosable(taskName, async, this.isEnabled());
+ this.addNested(nested, true);
+ return nested;
+ }
+
+ /**
+ * Creates a new nested {@link AutoCloseable} profiler
+ */
+ public InCodeProfilerAutoClosable nestedAC(final String taskName)
+ {
+ return this.nestedAC(taskName, false);
+ }
+
+ public String getPrettyPrinted()
+ {
+ if(!this.isEnabled())
+ {
+ return "";
+ }
+
+ final StringBuilder sb = new StringBuilder();
+ sb.append(System.lineSeparator());
+ sb.append("-------------------------------");
+ sb.append(System.lineSeparator());
+ sb.append("Root Parent Task");
+ sb.append(System.lineSeparator());
+ sb.append("-------------------------------");
+ sb.append(System.lineSeparator());
+
+ final long rootNanos = this.sw.getNanoTime();
+
+ sb.append(new TaskEntry(
+ rootNanos,
+ rootNanos,
+ 0,
+ "-",
+ this.gettaskName(),
+ rootNanos).format());
+ this.addNestedToStrBuilder(sb, rootNanos, 1);
+
+ return sb.toString();
+ }
+
+ protected void addNestedToStrBuilder(
+ final StringBuilder sb,
+ final long rootNanos,
+ final int hierarchicalPosition)
+ {
+ final Map> hierach =
+ this.nestedProfilers.stream().collect(
+ Collectors.groupingBy(
+ InCodeProfiler::gettaskName,
+ LinkedHashMap::new,
+ Collectors.toList()));
+
+ final long currentNanos = this.sw.getNanoTime();
+
+ long leftNanos = currentNanos;
+ for(final Entry> entry : hierach.entrySet())
+ {
+ final long groupMinNanos = entry.getValue()
+ .stream()
+ .mapToLong(hsw -> hsw.getStopWatch().getNanoTime())
+ .min()
+ .orElse(0);
+ final long groupMaxNanos = entry.getValue()
+ .stream()
+ .mapToLong(hsw -> hsw.getStopWatch().getNanoTime())
+ .max()
+ .orElse(0);
+
+ final int count = entry.getValue().size();
+
+ final long groupNestedNanos = entry.getValue()
+ .stream()
+ .mapToLong(hsw -> hsw.getStopWatch().getNanoTime())
+ .sum();
+
+ sb.append(new TaskEntry(
+ rootNanos,
+ currentNanos,
+ hierarchicalPosition,
+ "-",
+ entry.getKey(),
+ count,
+ groupMinNanos,
+ groupMaxNanos,
+ groupNestedNanos,
+ entry.getValue().stream().anyMatch(InCodeProfiler::isAsync)).format());
+
+ final long groupNestedNanosNotAsync = entry.getValue()
+ .stream()
+ .filter(InCodeProfiler::isNotAsync)
+ .mapToLong(hsw -> hsw.getStopWatch().getNanoTime())
+ .sum();
+ leftNanos -= groupNestedNanosNotAsync;
+
+ for(final InCodeProfiler hsw : entry.getValue())
+ {
+ hsw.addNestedToStrBuilder(sb, rootNanos, hierarchicalPosition + 1);
+ }
+ }
+
+ if(!hierach.isEmpty())
+ {
+ sb.append(new TaskEntry(
+ rootNanos,
+ currentNanos,
+ hierarchicalPosition,
+ "?",
+ "unspecified",
+ leftNanos).format());
+ }
+ }
+
+ public static InCodeProfiler createStarted(final String taskName)
+ {
+ final InCodeProfiler sw = new InCodeProfiler(taskName);
+ sw.start();
+ return sw;
+ }
+
+ protected record TaskEntry(
+ long rootNanos,
+ long parentNanos,
+ int hierarchicalPosition,
+ String delimiter,
+ String taskName,
+ long count,
+ long minNanos,
+ long maxNanos,
+ long currentNanos,
+ boolean async
+ )
+ {
+ public TaskEntry(
+ final long rootNanos,
+ final long parentNanos,
+ final int hierarchicalPosition,
+ final String delimiter,
+ final String taskName,
+ final long currentNanos)
+ {
+ this(
+ rootNanos,
+ parentNanos,
+ hierarchicalPosition,
+ delimiter,
+ taskName,
+ 0,
+ 0,
+ 0,
+ currentNanos,
+ false
+ );
+ }
+
+ public String format()
+ {
+ final String percentFormat = "%6.2f%%";
+ final String asyncPercent = " ASYNC";
+
+ final String multipleInfo = this.count() <= 1
+ ? ""
+ : String.format(
+ "; %dx; min=%.0fms; max=%.0fms",
+ this.count(),
+ this.minNanos() / NANOS_TO_MILLIS_FACTOR,
+ this.maxNanos() / NANOS_TO_MILLIS_FACTOR);
+
+ final double currentNanosDouble = this.currentNanos();
+ return String.format(
+ "%s%s %s %s %s [%.0fms%s]%s",
+ " ".repeat(this.hierarchicalPosition()),
+ this.async()
+ ? asyncPercent
+ : String.format(percentFormat, currentNanosDouble / this.rootNanos() * 100.0),
+ this.async()
+ ? asyncPercent
+ : String.format(percentFormat, currentNanosDouble / this.parentNanos() * 100.0),
+ this.delimiter(),
+ this.taskName(),
+ currentNanosDouble / NANOS_TO_MILLIS_FACTOR,
+ multipleInfo,
+ System.lineSeparator());
+ }
+ }
+}
diff --git a/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfilerAutoClosable.java b/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfilerAutoClosable.java
new file mode 100644
index 0000000..e481532
--- /dev/null
+++ b/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfilerAutoClosable.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright © 2024 XDEV Software (https://xdev.software)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package software.xdev.profiling;
+
+/**
+ * Same as {@link InCodeProfiler} but also implements {@link AutoCloseable}
+ *
+ * @see InCodeProfiler
+ */
+public class InCodeProfilerAutoClosable extends InCodeProfiler implements AutoCloseable
+{
+ public InCodeProfilerAutoClosable(final String taskName)
+ {
+ super(taskName);
+ }
+
+ public InCodeProfilerAutoClosable(final String taskName, final boolean async)
+ {
+ super(taskName, async);
+ }
+
+ public InCodeProfilerAutoClosable(final String taskName, final boolean async, final boolean enabled)
+ {
+ super(taskName, async, enabled);
+ }
+
+ @Override
+ public void close()
+ {
+ this.stop();
+ }
+
+ public static InCodeProfilerAutoClosable createStarted(final String taskName)
+ {
+ final InCodeProfilerAutoClosable sw = new InCodeProfilerAutoClosable(taskName);
+ sw.start();
+ return sw;
+ }
+}
From 058dab108c65628b99c14030f1017cb34b731376 Mon Sep 17 00:00:00 2001
From: AB
Date: Tue, 16 Apr 2024 09:18:05 +0200
Subject: [PATCH 05/27] Rename
---
.run/Run Demo.run.xml | 2 +-
CONTRIBUTING.md | 4 +-
README.md | 13 ++---
SECURITY.md | 2 +-
.../pom.xml | 4 +-
.../main/java/software/xdev/Application.java | 20 ++++----
.../pom.xml | 12 ++---
.../time/HierarchicalLoggingStopWatch.java | 19 ++++----
.../xdev/time/HierarchicalStopWatch.java | 47 ++++++++++---------
.../HierarchicalStopWatchAutoClosable.java | 18 +++----
pom.xml | 6 +--
11 files changed, 74 insertions(+), 73 deletions(-)
rename {hierarchical-in-code-profiler-demo => hierarchical-stopwatch-demo}/pom.xml (96%)
rename {hierarchical-in-code-profiler-demo => hierarchical-stopwatch-demo}/src/main/java/software/xdev/Application.java (55%)
rename {hierarchical-in-code-profiler => hierarchical-stopwatch}/pom.xml (95%)
rename hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeLogProfiler.java => hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalLoggingStopWatch.java (70%)
rename hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfiler.java => hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatch.java (80%)
rename hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfilerAutoClosable.java => hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatchAutoClosable.java (54%)
diff --git a/.run/Run Demo.run.xml b/.run/Run Demo.run.xml
index 5eaa97e..111c392 100644
--- a/.run/Run Demo.run.xml
+++ b/.run/Run Demo.run.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 8d92d3a..831e94e 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -33,10 +33,10 @@ You should have the following things installed:
* Ensure that the JDK/Java-Version is correct
-## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/hierarchical-in-code-profiler/release.yml?branch=master)](https://github.com/xdev-software/hierarchical-in-code-profiler/actions/workflows/release.yml)
+## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/hierarchical-stopwatch/release.yml?branch=master)](https://github.com/xdev-software/hierarchical-stopwatch/actions/workflows/release.yml)
Before releasing:
-* Consider doing a [test-deployment](https://github.com/xdev-software/hierarchical-in-code-profiler/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
+* Consider doing a [test-deployment](https://github.com/xdev-software/hierarchical-stopwatch/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
* Check the [changelog](CHANGELOG.md)
If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes
diff --git a/README.md b/README.md
index 2fe180a..e819df2 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,13 @@
-[![Latest version](https://img.shields.io/maven-central/v/software.xdev/hierarchical-in-code-profiler?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/hierarchical-in-code-profiler)
-[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/hierarchical-in-code-profiler/checkBuild.yml?branch=develop)](https://github.com/xdev-software/hierarchical-in-code-profiler/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
-[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_hierarchical-in-code-profiler&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_hierarchical-in-code-profiler)
+[![Latest version](https://img.shields.io/maven-central/v/software.xdev/hierarchical-stopwatch?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/hierarchical-stopwatch)
+[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/hierarchical-stopwatch/checkBuild.yml?branch=develop)](https://github.com/xdev-software/hierarchical-stopwatch/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
+[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_hierarchical-stopwatch&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_hierarchical-stopwatch)
-# hierarchical-in-code-profiler
+# hierarchical-stopwatch
+Represents a hierarchical stopwatch that can be used directly to track performance between methods and classes. It also supports async.
## Installation
-[Installation guide for the latest release](https://github.com/xdev-software/hierarchical-in-code-profiler/releases/latest#Installation)
+[Installation guide for the latest release](https://github.com/xdev-software/hierarchical-stopwatch/releases/latest#Installation)
## Support
@@ -16,4 +17,4 @@ If you need support as soon as possible and you can't wait for any pull request,
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.
## Dependencies and Licenses
-View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/hierarchical-in-code-profiler/dependencies)
+View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/hierarchical-stopwatch/dependencies)
diff --git a/SECURITY.md b/SECURITY.md
index d2752c4..59faafd 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -2,4 +2,4 @@
## Reporting a Vulnerability
-Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/hierarchical-in-code-profiler/security/advisories/new).
+Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/hierarchical-stopwatch/security/advisories/new).
diff --git a/hierarchical-in-code-profiler-demo/pom.xml b/hierarchical-stopwatch-demo/pom.xml
similarity index 96%
rename from hierarchical-in-code-profiler-demo/pom.xml
rename to hierarchical-stopwatch-demo/pom.xml
index d812cdc..dfbac5b 100644
--- a/hierarchical-in-code-profiler-demo/pom.xml
+++ b/hierarchical-stopwatch-demo/pom.xml
@@ -5,7 +5,7 @@
4.0.0
software.xdev
- hierarchical-in-code-profiler-demo
+ hierarchical-stopwatch-demo
1.0.0-SNAPSHOT
jar
@@ -29,7 +29,7 @@
software.xdev
- hierarchical-in-code-profiler
+ hierarchical-stopwatch
${project.version}
diff --git a/hierarchical-in-code-profiler-demo/src/main/java/software/xdev/Application.java b/hierarchical-stopwatch-demo/src/main/java/software/xdev/Application.java
similarity index 55%
rename from hierarchical-in-code-profiler-demo/src/main/java/software/xdev/Application.java
rename to hierarchical-stopwatch-demo/src/main/java/software/xdev/Application.java
index 6125036..885ee79 100644
--- a/hierarchical-in-code-profiler-demo/src/main/java/software/xdev/Application.java
+++ b/hierarchical-stopwatch-demo/src/main/java/software/xdev/Application.java
@@ -4,39 +4,38 @@
import java.util.concurrent.CompletableFuture;
import java.util.stream.IntStream;
-import software.xdev.profiling.InCodeLogProfiler;
-import software.xdev.profiling.InCodeProfilerAutoClosable;
+import software.xdev.time.HierarchicalLoggingStopWatch;
public final class Application
{
public static void main(final String[] args)
{
- try(final InCodeLogProfiler profiler = InCodeLogProfiler.createStarted(
+ try(final var profiler = HierarchicalLoggingStopWatch.createStarted(
"Run dummy",
System.out::println, // Could also be LOGGER::debug
true)) // Could also be LOGGER.isDebugEnabled()
{
final List> completableFutures;
- try(final InCodeProfilerAutoClosable ignored = profiler.nestedAC("Launch tasks"))
+ try(final var ignored = profiler.nestedAC("Launch tasks"))
{
completableFutures = IntStream.of(1, 2, 3)
.mapToObj(i -> CompletableFuture.runAsync(() -> {
- try(final InCodeProfilerAutoClosable process = profiler.nestedAC("Process " + i, true))
+ try(final var process = profiler.nestedAC("Process " + i, true))
{
- try(final InCodeProfilerAutoClosable ignore = process.nestedAC("Fetch"))
+ try(final var ignore = process.nestedAC("Fetch"))
{
sleep(5);
}
- try(final InCodeProfilerAutoClosable ignore = process.nestedAC("Process"))
+ try(final var ignore = process.nestedAC("Process"))
{
sleep(i * 5);
}
if(i % 2 == 0)
{
- try(final InCodeProfilerAutoClosable ignore = process.nestedAC("Finalize"))
+ try(final var ignore = process.nestedAC("Finalize"))
{
sleep(5);
}
@@ -46,7 +45,7 @@ public static void main(final String[] args)
.toList();
}
- try(final InCodeProfilerAutoClosable ignored = profiler.nestedAC("Wait for tasks"))
+ try(final var ignored = profiler.nestedAC("Wait for tasks"))
{
completableFutures.forEach(CompletableFuture::join);
}
@@ -61,8 +60,7 @@ private static void sleep(final int ms)
}
catch(final InterruptedException iex)
{
- throw new RuntimeException("Interrupted");
- // Thread.currentThread().interrupt();
+ Thread.currentThread().interrupt();
}
}
diff --git a/hierarchical-in-code-profiler/pom.xml b/hierarchical-stopwatch/pom.xml
similarity index 95%
rename from hierarchical-in-code-profiler/pom.xml
rename to hierarchical-stopwatch/pom.xml
index d45acb6..c7a2e9e 100644
--- a/hierarchical-in-code-profiler/pom.xml
+++ b/hierarchical-stopwatch/pom.xml
@@ -5,17 +5,17 @@
4.0.0
software.xdev
- hierarchical-in-code-profiler
+ hierarchical-stopwatch
1.0.0-SNAPSHOT
jar
- hierarchical-in-code-profiler
- hierarchical-in-code-profiler
- https://github.com/xdev-software/hierarchical-in-code-profiler
+ hierarchical-stopwatch
+ hierarchical-stopwatch
+ https://github.com/xdev-software/hierarchical-stopwatch
- https://github.com/xdev-software/hierarchical-in-code-profiler
- scm:git:https://github.com/xdev-software/hierarchical-in-code-profiler.git
+ https://github.com/xdev-software/hierarchical-stopwatch
+ scm:git:https://github.com/xdev-software/hierarchical-stopwatch.git
2024
diff --git a/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeLogProfiler.java b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalLoggingStopWatch.java
similarity index 70%
rename from hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeLogProfiler.java
rename to hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalLoggingStopWatch.java
index 9378ea3..7cc96b4 100644
--- a/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeLogProfiler.java
+++ b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalLoggingStopWatch.java
@@ -13,22 +13,22 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package software.xdev.profiling;
+package software.xdev.time;
import java.util.function.Consumer;
/**
- * Same as {@link InCodeProfilerAutoClosable} but with a Consumer that handles
- * {@link InCodeProfiler#getPrettyPrinted()}
+ * Same as {@link HierarchicalStopWatchAutoClosable} but with a Consumer that handles
+ * {@link HierarchicalStopWatch#getPrettyPrinted()}
*
- * @see InCodeProfilerAutoClosable
+ * @see HierarchicalStopWatchAutoClosable
*/
-public class InCodeLogProfiler extends InCodeProfilerAutoClosable
+public class HierarchicalLoggingStopWatch extends HierarchicalStopWatchAutoClosable
{
protected final Consumer logConsumer;
- public InCodeLogProfiler(
+ public HierarchicalLoggingStopWatch(
final String taskName,
final Consumer logConsumer,
final boolean async,
@@ -49,18 +49,19 @@ public void close()
}
}
- public static InCodeLogProfiler createStarted(
+ public static HierarchicalLoggingStopWatch createStarted(
final String taskName,
final Consumer logConsumer,
final boolean async,
final boolean enabled)
{
- final InCodeLogProfiler sw = new InCodeLogProfiler(taskName, logConsumer, async, enabled);
+ final HierarchicalLoggingStopWatch sw = new HierarchicalLoggingStopWatch(taskName, logConsumer, async,
+ enabled);
sw.start();
return sw;
}
- public static InCodeLogProfiler createStarted(
+ public static HierarchicalLoggingStopWatch createStarted(
final String taskname,
final Consumer logConsumer,
final boolean enabled)
diff --git a/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfiler.java b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatch.java
similarity index 80%
rename from hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfiler.java
rename to hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatch.java
index 49b9d99..667e0ca 100644
--- a/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfiler.java
+++ b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatch.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package software.xdev.profiling;
+package software.xdev.time;
import java.util.ArrayList;
import java.util.Collections;
@@ -28,7 +28,7 @@
/**
- * Presents a hierarchical Profiler based on StopWatches
+ * Presents a hierarchical StopWatch
*
* Example:
*
@@ -50,7 +50,7 @@
*
*
*/
-public class InCodeProfiler
+public class HierarchicalStopWatch
{
protected static final double NANOS_TO_MILLIS_FACTOR = 1000000.0;
@@ -60,9 +60,9 @@ public class InCodeProfiler
protected final StopWatch sw = new StopWatch();
- protected final List nestedProfilers = Collections.synchronizedList(new ArrayList<>());
+ protected final List nestedProfilers = Collections.synchronizedList(new ArrayList<>());
- public InCodeProfiler(final String taskName, final boolean async, final boolean enabled)
+ public HierarchicalStopWatch(final String taskName, final boolean async, final boolean enabled)
{
super();
@@ -71,12 +71,12 @@ public InCodeProfiler(final String taskName, final boolean async, final boolean
this.enabled = enabled;
}
- public InCodeProfiler(final String taskName, final boolean async)
+ public HierarchicalStopWatch(final String taskName, final boolean async)
{
this(taskName, async, true);
}
- public InCodeProfiler(final String taskName)
+ public HierarchicalStopWatch(final String taskName)
{
this(taskName, false);
}
@@ -129,13 +129,13 @@ public void stop()
public void stopAll()
{
this.stop();
- for(final InCodeProfiler hsw : this.nestedProfilers)
+ for(final HierarchicalStopWatch hsw : this.nestedProfilers)
{
hsw.stopAll();
}
}
- protected void addNested(final InCodeProfiler nested, final boolean start)
+ protected void addNested(final HierarchicalStopWatch nested, final boolean start)
{
if(!this.isEnabled())
{
@@ -153,9 +153,9 @@ protected void addNested(final InCodeProfiler nested, final boolean start)
/**
* Creates a new nested profiler
*/
- public InCodeProfiler nested(final String taskName, final boolean async)
+ public HierarchicalStopWatch nested(final String taskName, final boolean async)
{
- final InCodeProfiler nested = new InCodeProfiler(taskName, async, this.isEnabled());
+ final HierarchicalStopWatch nested = new HierarchicalStopWatch(taskName, async, this.isEnabled());
this.addNested(nested, true);
@@ -165,7 +165,7 @@ public InCodeProfiler nested(final String taskName, final boolean async)
/**
* Creates a new nested profiler
*/
- public InCodeProfiler nested(final String taskName)
+ public HierarchicalStopWatch nested(final String taskName)
{
return this.nested(taskName, false);
}
@@ -173,9 +173,10 @@ public InCodeProfiler nested(final String taskName)
/**
* Creates a new nested {@link AutoCloseable} profiler
*/
- public InCodeProfilerAutoClosable nestedAC(final String taskName, final boolean async)
+ public HierarchicalStopWatchAutoClosable nestedAC(final String taskName, final boolean async)
{
- final InCodeProfilerAutoClosable nested = new InCodeProfilerAutoClosable(taskName, async, this.isEnabled());
+ final HierarchicalStopWatchAutoClosable nested =
+ new HierarchicalStopWatchAutoClosable(taskName, async, this.isEnabled());
this.addNested(nested, true);
return nested;
}
@@ -183,7 +184,7 @@ public InCodeProfilerAutoClosable nestedAC(final String taskName, final boolean
/**
* Creates a new nested {@link AutoCloseable} profiler
*/
- public InCodeProfilerAutoClosable nestedAC(final String taskName)
+ public HierarchicalStopWatchAutoClosable nestedAC(final String taskName)
{
return this.nestedAC(taskName, false);
}
@@ -223,17 +224,17 @@ protected void addNestedToStrBuilder(
final long rootNanos,
final int hierarchicalPosition)
{
- final Map> hierach =
+ final Map> hierach =
this.nestedProfilers.stream().collect(
Collectors.groupingBy(
- InCodeProfiler::gettaskName,
+ HierarchicalStopWatch::gettaskName,
LinkedHashMap::new,
Collectors.toList()));
final long currentNanos = this.sw.getNanoTime();
long leftNanos = currentNanos;
- for(final Entry> entry : hierach.entrySet())
+ for(final Entry> entry : hierach.entrySet())
{
final long groupMinNanos = entry.getValue()
.stream()
@@ -263,16 +264,16 @@ protected void addNestedToStrBuilder(
groupMinNanos,
groupMaxNanos,
groupNestedNanos,
- entry.getValue().stream().anyMatch(InCodeProfiler::isAsync)).format());
+ entry.getValue().stream().anyMatch(HierarchicalStopWatch::isAsync)).format());
final long groupNestedNanosNotAsync = entry.getValue()
.stream()
- .filter(InCodeProfiler::isNotAsync)
+ .filter(HierarchicalStopWatch::isNotAsync)
.mapToLong(hsw -> hsw.getStopWatch().getNanoTime())
.sum();
leftNanos -= groupNestedNanosNotAsync;
- for(final InCodeProfiler hsw : entry.getValue())
+ for(final HierarchicalStopWatch hsw : entry.getValue())
{
hsw.addNestedToStrBuilder(sb, rootNanos, hierarchicalPosition + 1);
}
@@ -290,9 +291,9 @@ protected void addNestedToStrBuilder(
}
}
- public static InCodeProfiler createStarted(final String taskName)
+ public static HierarchicalStopWatch createStarted(final String taskName)
{
- final InCodeProfiler sw = new InCodeProfiler(taskName);
+ final HierarchicalStopWatch sw = new HierarchicalStopWatch(taskName);
sw.start();
return sw;
}
diff --git a/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfilerAutoClosable.java b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatchAutoClosable.java
similarity index 54%
rename from hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfilerAutoClosable.java
rename to hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatchAutoClosable.java
index e481532..0a085a1 100644
--- a/hierarchical-in-code-profiler/src/main/java/software/xdev/profiling/InCodeProfilerAutoClosable.java
+++ b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatchAutoClosable.java
@@ -13,26 +13,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package software.xdev.profiling;
+package software.xdev.time;
/**
- * Same as {@link InCodeProfiler} but also implements {@link AutoCloseable}
+ * Same as {@link HierarchicalStopWatch} but also implements {@link AutoCloseable}
*
- * @see InCodeProfiler
+ * @see HierarchicalStopWatch
*/
-public class InCodeProfilerAutoClosable extends InCodeProfiler implements AutoCloseable
+public class HierarchicalStopWatchAutoClosable extends HierarchicalStopWatch implements AutoCloseable
{
- public InCodeProfilerAutoClosable(final String taskName)
+ public HierarchicalStopWatchAutoClosable(final String taskName)
{
super(taskName);
}
- public InCodeProfilerAutoClosable(final String taskName, final boolean async)
+ public HierarchicalStopWatchAutoClosable(final String taskName, final boolean async)
{
super(taskName, async);
}
- public InCodeProfilerAutoClosable(final String taskName, final boolean async, final boolean enabled)
+ public HierarchicalStopWatchAutoClosable(final String taskName, final boolean async, final boolean enabled)
{
super(taskName, async, enabled);
}
@@ -43,9 +43,9 @@ public void close()
this.stop();
}
- public static InCodeProfilerAutoClosable createStarted(final String taskName)
+ public static HierarchicalStopWatchAutoClosable createStarted(final String taskName)
{
- final InCodeProfilerAutoClosable sw = new InCodeProfilerAutoClosable(taskName);
+ final HierarchicalStopWatchAutoClosable sw = new HierarchicalStopWatchAutoClosable(taskName);
sw.start();
return sw;
}
diff --git a/pom.xml b/pom.xml
index 8e94148..91268cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
software.xdev
- hierarchical-in-code-profiler-root
+ hierarchical-stopwatch-root
1.0.0-SNAPSHOT
pom
@@ -15,8 +15,8 @@
- hierarchical-in-code-profiler
- hierarchical-in-code-profiler-demo
+ hierarchical-stopwatch
+ hierarchical-stopwatch-demo
From 85f98131a35c59c4c80a8f9595e3eac04c4d1425 Mon Sep 17 00:00:00 2001
From: AB
Date: Tue, 16 Apr 2024 09:24:09 +0200
Subject: [PATCH 06/27] Update README.md
---
README.md | 27 ++++++++++++++++++++++++++-
1 file changed, 26 insertions(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e819df2..c26215f 100644
--- a/README.md
+++ b/README.md
@@ -6,10 +6,35 @@
Represents a hierarchical stopwatch that can be used directly to track performance between methods and classes. It also supports async.
+Example output:
+```
+-------------------------------
+Root Parent Task
+-------------------------------
+100,00% 100,00% - Run dummy [42ms]
+ 11,20% 11,20% - Launch tasks [5ms]
+ 88,74% 88,74% - Wait for tasks [38ms]
+ ASYNC ASYNC - Process 1 [11ms]
+ 12,45% 46,81% - Fetch [5ms]
+ 14,01% 52,70% - Process [6ms]
+ 0,13% 0,49% ? unspecified [0ms]
+ ASYNC ASYNC - Process 2 [32ms]
+ 12,44% 16,36% - Fetch [5ms]
+ 49,53% 65,14% - Process [21ms]
+ 13,95% 18,35% - Finalize [6ms]
+ 0,11% 0,14% ? unspecified [0ms]
+ ASYNC ASYNC - Process 3 [22ms]
+ 12,44% 23,71% - Fetch [5ms]
+ 39,99% 76,20% - Process [17ms]
+ 0,05% 0,10% ? unspecified [0ms]
+ 0,06% 0,06% ? unspecified [0ms]
+```
+
+An [usage example is available in the demo project](./hierarchical-stopwatch-demo/src/main/java/software/xdev/Application.java).
+
## Installation
[Installation guide for the latest release](https://github.com/xdev-software/hierarchical-stopwatch/releases/latest#Installation)
-
## Support
If you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services/support).
From f3860071f88bc0eb21ac97fafcc1263a05df3d41 Mon Sep 17 00:00:00 2001
From: AB
Date: Tue, 16 Apr 2024 09:25:05 +0200
Subject: [PATCH 07/27] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index c26215f..8680301 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
# hierarchical-stopwatch
-Represents a hierarchical stopwatch that can be used directly to track performance between methods and classes. It also supports async.
+A hierarchical stopwatch that supports nesting and can be used to track performance between methods and classes. It also supports async.
Example output:
```
From cf2544419c91d83326e37b2d8e9396d9a673b405 Mon Sep 17 00:00:00 2001
From: AB
Date: Tue, 16 Apr 2024 09:29:27 +0200
Subject: [PATCH 08/27] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index 8680301..a43b8a1 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
# hierarchical-stopwatch
-A hierarchical stopwatch that supports nesting and can be used to track performance between methods and classes. It also supports async.
+A hierarchical stopwatch that supports nesting and can be used to track performance across methods and classes. It also supports async.
Example output:
```
From dd6d444543c75417751c20a5552f006f17afa94e Mon Sep 17 00:00:00 2001
From: AB
Date: Tue, 16 Apr 2024 09:33:02 +0200
Subject: [PATCH 09/27] Update CHANGELOG.md
---
CHANGELOG.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index e69de29..acedcb8 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -0,0 +1,2 @@
+# 1.0.0
+Initial release
\ No newline at end of file
From 5d541443f1dd17542378ffa1aff5febfd128bc14 Mon Sep 17 00:00:00 2001
From: AB
Date: Tue, 16 Apr 2024 09:33:13 +0200
Subject: [PATCH 10/27] Update CHANGELOG.md
---
CHANGELOG.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index acedcb8..407e09b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,2 +1,2 @@
# 1.0.0
-Initial release
\ No newline at end of file
+Initial release
From ff406bd8cbad84337eb68b94426beb4ee5f1eda5 Mon Sep 17 00:00:00 2001
From: GitHub Actions
Date: Tue, 16 Apr 2024 07:35:18 +0000
Subject: [PATCH 11/27] Release 1.0.0
---
hierarchical-stopwatch-demo/pom.xml | 2 +-
hierarchical-stopwatch/pom.xml | 2 +-
pom.xml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hierarchical-stopwatch-demo/pom.xml b/hierarchical-stopwatch-demo/pom.xml
index 3159199..28d5a0e 100644
--- a/hierarchical-stopwatch-demo/pom.xml
+++ b/hierarchical-stopwatch-demo/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch-demo
- 1.0.0-SNAPSHOT
+ 1.0.0
jar
diff --git a/hierarchical-stopwatch/pom.xml b/hierarchical-stopwatch/pom.xml
index e11ec4b..48cfc75 100644
--- a/hierarchical-stopwatch/pom.xml
+++ b/hierarchical-stopwatch/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch
- 1.0.0-SNAPSHOT
+ 1.0.0
jar
hierarchical-stopwatch
diff --git a/pom.xml b/pom.xml
index 91268cc..430a3d6 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch-root
- 1.0.0-SNAPSHOT
+ 1.0.0
pom
From 6db92fd19669c38316370014d61b258f6b1098f2 Mon Sep 17 00:00:00 2001
From: GitHub Actions
Date: Tue, 16 Apr 2024 07:37:22 +0000
Subject: [PATCH 12/27] Preparing for next development iteration
---
hierarchical-stopwatch-demo/pom.xml | 2 +-
hierarchical-stopwatch/pom.xml | 2 +-
pom.xml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hierarchical-stopwatch-demo/pom.xml b/hierarchical-stopwatch-demo/pom.xml
index 28d5a0e..41f8665 100644
--- a/hierarchical-stopwatch-demo/pom.xml
+++ b/hierarchical-stopwatch-demo/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch-demo
- 1.0.0
+ 1.0.1-SNAPSHOT
jar
diff --git a/hierarchical-stopwatch/pom.xml b/hierarchical-stopwatch/pom.xml
index 48cfc75..e292570 100644
--- a/hierarchical-stopwatch/pom.xml
+++ b/hierarchical-stopwatch/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch
- 1.0.0
+ 1.0.1-SNAPSHOT
jar
hierarchical-stopwatch
diff --git a/pom.xml b/pom.xml
index 430a3d6..b6e76f0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch-root
- 1.0.0
+ 1.0.1-SNAPSHOT
pom
From 06a5c0625298e0b0bad079f5f93b3a902ed08a92 Mon Sep 17 00:00:00 2001
From: Alex B <45384811+AB-xdev@users.noreply.github.com>
Date: Wed, 17 Apr 2024 08:29:32 +0200
Subject: [PATCH 13/27] Update README.md
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index a43b8a1..93cd067 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
# hierarchical-stopwatch
-A hierarchical stopwatch that supports nesting and can be used to track performance across methods and classes. It also supports async.
+A hierarchical Java stopwatch that supports nesting and can be used to track performance across methods and classes. It also supports async.
Example output:
```
From 94953809b000f8364baed17d20d9112f0b75e825 Mon Sep 17 00:00:00 2001
From: AB
Date: Wed, 17 Apr 2024 08:50:39 +0200
Subject: [PATCH 14/27] Various improvements
* Default stopwatch is now AutoCloseable
Co-Authored-By: Johannes Rabauer <8188460+johannesrabauer@users.noreply.github.com>
---
CHANGELOG.md | 3 ++
hierarchical-stopwatch-demo/pom.xml | 2 +-
.../main/java/software/xdev/Application.java | 15 +++---
hierarchical-stopwatch/pom.xml | 2 +-
.../time/HierarchicalLoggingStopWatch.java | 10 ++--
.../xdev/time/HierarchicalStopWatch.java | 29 +++--------
.../HierarchicalStopWatchAutoClosable.java | 52 -------------------
pom.xml | 2 +-
8 files changed, 26 insertions(+), 89 deletions(-)
delete mode 100644 hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatchAutoClosable.java
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 407e09b..f31489f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,2 +1,5 @@
+# 1.1.0
+* Consolidated ``AutoCloseable`` into ``HierarchicalStopWatch``
+
# 1.0.0
Initial release
diff --git a/hierarchical-stopwatch-demo/pom.xml b/hierarchical-stopwatch-demo/pom.xml
index 41f8665..721b784 100644
--- a/hierarchical-stopwatch-demo/pom.xml
+++ b/hierarchical-stopwatch-demo/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch-demo
- 1.0.1-SNAPSHOT
+ 1.1.0-SNAPSHOT
jar
diff --git a/hierarchical-stopwatch-demo/src/main/java/software/xdev/Application.java b/hierarchical-stopwatch-demo/src/main/java/software/xdev/Application.java
index 885ee79..f97ee6a 100644
--- a/hierarchical-stopwatch-demo/src/main/java/software/xdev/Application.java
+++ b/hierarchical-stopwatch-demo/src/main/java/software/xdev/Application.java
@@ -5,37 +5,38 @@
import java.util.stream.IntStream;
import software.xdev.time.HierarchicalLoggingStopWatch;
+import software.xdev.time.HierarchicalStopWatch;
public final class Application
{
public static void main(final String[] args)
{
- try(final var profiler = HierarchicalLoggingStopWatch.createStarted(
+ try(final HierarchicalStopWatch dummySw = HierarchicalLoggingStopWatch.createStarted(
"Run dummy",
System.out::println, // Could also be LOGGER::debug
true)) // Could also be LOGGER.isDebugEnabled()
{
final List> completableFutures;
- try(final var ignored = profiler.nestedAC("Launch tasks"))
+ try(final HierarchicalStopWatch ignored = dummySw.nested("Launch tasks"))
{
completableFutures = IntStream.of(1, 2, 3)
.mapToObj(i -> CompletableFuture.runAsync(() -> {
- try(final var process = profiler.nestedAC("Process " + i, true))
+ try(final var processSw = dummySw.nested("Process " + i, true))
{
- try(final var ignore = process.nestedAC("Fetch"))
+ try(final var ignore = processSw.nested("Fetch"))
{
sleep(5);
}
- try(final var ignore = process.nestedAC("Process"))
+ try(final var ignore = processSw.nested("Process"))
{
sleep(i * 5);
}
if(i % 2 == 0)
{
- try(final var ignore = process.nestedAC("Finalize"))
+ try(final var ignore = processSw.nested("Finalize"))
{
sleep(5);
}
@@ -45,7 +46,7 @@ public static void main(final String[] args)
.toList();
}
- try(final var ignored = profiler.nestedAC("Wait for tasks"))
+ try(final HierarchicalStopWatch ignore = dummySw.nested("Wait for tasks"))
{
completableFutures.forEach(CompletableFuture::join);
}
diff --git a/hierarchical-stopwatch/pom.xml b/hierarchical-stopwatch/pom.xml
index e292570..4eeae77 100644
--- a/hierarchical-stopwatch/pom.xml
+++ b/hierarchical-stopwatch/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch
- 1.0.1-SNAPSHOT
+ 1.1.0-SNAPSHOT
jar
hierarchical-stopwatch
diff --git a/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalLoggingStopWatch.java b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalLoggingStopWatch.java
index 7cc96b4..bf6bfda 100644
--- a/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalLoggingStopWatch.java
+++ b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalLoggingStopWatch.java
@@ -19,12 +19,12 @@
/**
- * Same as {@link HierarchicalStopWatchAutoClosable} but with a Consumer that handles
+ * Same as {@link HierarchicalStopWatch} but with a Consumer that handles
* {@link HierarchicalStopWatch#getPrettyPrinted()}
*
- * @see HierarchicalStopWatchAutoClosable
+ * @see HierarchicalStopWatch
*/
-public class HierarchicalLoggingStopWatch extends HierarchicalStopWatchAutoClosable
+public class HierarchicalLoggingStopWatch extends HierarchicalStopWatch
{
protected final Consumer logConsumer;
@@ -62,10 +62,10 @@ public static HierarchicalLoggingStopWatch createStarted(
}
public static HierarchicalLoggingStopWatch createStarted(
- final String taskname,
+ final String taskName,
final Consumer logConsumer,
final boolean enabled)
{
- return createStarted(taskname, logConsumer, false, enabled);
+ return createStarted(taskName, logConsumer, false, enabled);
}
}
diff --git a/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatch.java b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatch.java
index 667e0ca..d99c508 100644
--- a/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatch.java
+++ b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatch.java
@@ -50,7 +50,7 @@
*
*
*/
-public class HierarchicalStopWatch
+public class HierarchicalStopWatch implements AutoCloseable
{
protected static final double NANOS_TO_MILLIS_FACTOR = 1000000.0;
@@ -123,6 +123,12 @@ public void stop()
}
}
+ @Override
+ public void close()
+ {
+ this.stop();
+ }
+
/**
* Tries to stop all nested profilers
*/
@@ -156,9 +162,7 @@ protected void addNested(final HierarchicalStopWatch nested, final boolean start
public HierarchicalStopWatch nested(final String taskName, final boolean async)
{
final HierarchicalStopWatch nested = new HierarchicalStopWatch(taskName, async, this.isEnabled());
-
this.addNested(nested, true);
-
return nested;
}
@@ -170,25 +174,6 @@ public HierarchicalStopWatch nested(final String taskName)
return this.nested(taskName, false);
}
- /**
- * Creates a new nested {@link AutoCloseable} profiler
- */
- public HierarchicalStopWatchAutoClosable nestedAC(final String taskName, final boolean async)
- {
- final HierarchicalStopWatchAutoClosable nested =
- new HierarchicalStopWatchAutoClosable(taskName, async, this.isEnabled());
- this.addNested(nested, true);
- return nested;
- }
-
- /**
- * Creates a new nested {@link AutoCloseable} profiler
- */
- public HierarchicalStopWatchAutoClosable nestedAC(final String taskName)
- {
- return this.nestedAC(taskName, false);
- }
-
public String getPrettyPrinted()
{
if(!this.isEnabled())
diff --git a/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatchAutoClosable.java b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatchAutoClosable.java
deleted file mode 100644
index 0a085a1..0000000
--- a/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatchAutoClosable.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright © 2024 XDEV Software (https://xdev.software)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package software.xdev.time;
-
-/**
- * Same as {@link HierarchicalStopWatch} but also implements {@link AutoCloseable}
- *
- * @see HierarchicalStopWatch
- */
-public class HierarchicalStopWatchAutoClosable extends HierarchicalStopWatch implements AutoCloseable
-{
- public HierarchicalStopWatchAutoClosable(final String taskName)
- {
- super(taskName);
- }
-
- public HierarchicalStopWatchAutoClosable(final String taskName, final boolean async)
- {
- super(taskName, async);
- }
-
- public HierarchicalStopWatchAutoClosable(final String taskName, final boolean async, final boolean enabled)
- {
- super(taskName, async, enabled);
- }
-
- @Override
- public void close()
- {
- this.stop();
- }
-
- public static HierarchicalStopWatchAutoClosable createStarted(final String taskName)
- {
- final HierarchicalStopWatchAutoClosable sw = new HierarchicalStopWatchAutoClosable(taskName);
- sw.start();
- return sw;
- }
-}
diff --git a/pom.xml b/pom.xml
index b6e76f0..f751ad2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch-root
- 1.0.1-SNAPSHOT
+ 1.1.0-SNAPSHOT
pom
From 49e8b0bfebdae8f2897921f3331a042adc041346 Mon Sep 17 00:00:00 2001
From: GitHub Actions
Date: Wed, 17 Apr 2024 08:30:27 +0000
Subject: [PATCH 15/27] Release 1.1.0
---
hierarchical-stopwatch-demo/pom.xml | 2 +-
hierarchical-stopwatch/pom.xml | 2 +-
pom.xml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hierarchical-stopwatch-demo/pom.xml b/hierarchical-stopwatch-demo/pom.xml
index 721b784..4be002d 100644
--- a/hierarchical-stopwatch-demo/pom.xml
+++ b/hierarchical-stopwatch-demo/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch-demo
- 1.1.0-SNAPSHOT
+ 1.1.0
jar
diff --git a/hierarchical-stopwatch/pom.xml b/hierarchical-stopwatch/pom.xml
index 4eeae77..598a85d 100644
--- a/hierarchical-stopwatch/pom.xml
+++ b/hierarchical-stopwatch/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch
- 1.1.0-SNAPSHOT
+ 1.1.0
jar
hierarchical-stopwatch
diff --git a/pom.xml b/pom.xml
index f751ad2..7e3b942 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch-root
- 1.1.0-SNAPSHOT
+ 1.1.0
pom
From 4ac01a8ad2e96e2b4b5457551f7dc31c5fc032c4 Mon Sep 17 00:00:00 2001
From: GitHub Actions
Date: Wed, 17 Apr 2024 08:34:57 +0000
Subject: [PATCH 16/27] Preparing for next development iteration
---
hierarchical-stopwatch-demo/pom.xml | 2 +-
hierarchical-stopwatch/pom.xml | 2 +-
pom.xml | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hierarchical-stopwatch-demo/pom.xml b/hierarchical-stopwatch-demo/pom.xml
index 4be002d..36c26b2 100644
--- a/hierarchical-stopwatch-demo/pom.xml
+++ b/hierarchical-stopwatch-demo/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch-demo
- 1.1.0
+ 1.1.1-SNAPSHOT
jar
diff --git a/hierarchical-stopwatch/pom.xml b/hierarchical-stopwatch/pom.xml
index 598a85d..c766198 100644
--- a/hierarchical-stopwatch/pom.xml
+++ b/hierarchical-stopwatch/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch
- 1.1.0
+ 1.1.1-SNAPSHOT
jar
hierarchical-stopwatch
diff --git a/pom.xml b/pom.xml
index 7e3b942..4b4a71a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch-root
- 1.1.0
+ 1.1.1-SNAPSHOT
pom
From 4a7b4a066636ba31cc16f6a689f072a0959fb699 Mon Sep 17 00:00:00 2001
From: AB
Date: Tue, 23 Apr 2024 10:29:34 +0200
Subject: [PATCH 17/27] Rename I
---
.run/Run Demo.run.xml | 2 +-
CONTRIBUTING.md | 4 ++--
README.md | 12 ++++++------
SECURITY.md | 2 +-
pom.xml | 6 +++---
template-placeholder-demo/pom.xml | 4 ++--
template-placeholder/pom.xml | 12 ++++++------
7 files changed, 21 insertions(+), 21 deletions(-)
diff --git a/.run/Run Demo.run.xml b/.run/Run Demo.run.xml
index 5fb2bc2..111c392 100644
--- a/.run/Run Demo.run.xml
+++ b/.run/Run Demo.run.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d241a28..831e94e 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -33,10 +33,10 @@ You should have the following things installed:
* Ensure that the JDK/Java-Version is correct
-## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/release.yml?branch=master)](https://github.com/xdev-software/template-placeholder/actions/workflows/release.yml)
+## Releasing [![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/hierarchical-stopwatch/release.yml?branch=master)](https://github.com/xdev-software/hierarchical-stopwatch/actions/workflows/release.yml)
Before releasing:
-* Consider doing a [test-deployment](https://github.com/xdev-software/template-placeholder/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
+* Consider doing a [test-deployment](https://github.com/xdev-software/hierarchical-stopwatch/actions/workflows/test-deploy.yml?query=branch%3Adevelop) before actually releasing.
* Check the [changelog](CHANGELOG.md)
If the ``develop`` is ready for release, create a pull request to the ``master``-Branch and merge the changes
diff --git a/README.md b/README.md
index 8da47a0..87928a3 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,12 @@
-[![Latest version](https://img.shields.io/maven-central/v/software.xdev/template-placeholder?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/template-placeholder)
-[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/template-placeholder/checkBuild.yml?branch=develop)](https://github.com/xdev-software/template-placeholder/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
-[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_template-placeholder&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_template-placeholder)
+[![Latest version](https://img.shields.io/maven-central/v/software.xdev/hierarchical-stopwatch?logo=apache%20maven)](https://mvnrepository.com/artifact/software.xdev/hierarchical-stopwatch)
+[![Build](https://img.shields.io/github/actions/workflow/status/xdev-software/hierarchical-stopwatch/checkBuild.yml?branch=develop)](https://github.com/xdev-software/hierarchical-stopwatch/actions/workflows/checkBuild.yml?query=branch%3Adevelop)
+[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=xdev-software_hierarchical-stopwatch&metric=alert_status)](https://sonarcloud.io/dashboard?id=xdev-software_hierarchical-stopwatch)
-# template-placeholder
+# hierarchical-stopwatch
## Installation
-[Installation guide for the latest release](https://github.com/xdev-software/template-placeholder/releases/latest#Installation)
+[Installation guide for the latest release](https://github.com/xdev-software/hierarchical-stopwatch/releases/latest#Installation)
## Support
If you need support as soon as possible and you can't wait for any pull request, feel free to use [our support](https://xdev.software/en/services/support).
@@ -15,4 +15,4 @@ If you need support as soon as possible and you can't wait for any pull request,
See the [contributing guide](./CONTRIBUTING.md) for detailed instructions on how to get started with our project.
## Dependencies and Licenses
-View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/template-placeholder/dependencies)
+View the [license of the current project](LICENSE) or the [summary including all dependencies](https://xdev-software.github.io/hierarchical-stopwatch/dependencies)
diff --git a/SECURITY.md b/SECURITY.md
index 34b9514..59faafd 100644
--- a/SECURITY.md
+++ b/SECURITY.md
@@ -2,4 +2,4 @@
## Reporting a Vulnerability
-Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/template-placeholder/security/advisories/new).
+Please report a security vulnerability [on GitHub Security Advisories](https://github.com/xdev-software/hierarchical-stopwatch/security/advisories/new).
diff --git a/pom.xml b/pom.xml
index 5da2110..91268cc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -5,7 +5,7 @@
4.0.0
software.xdev
- template-placeholder-root
+ hierarchical-stopwatch-root
1.0.0-SNAPSHOT
pom
@@ -15,8 +15,8 @@
- template-placeholder
- template-placeholder-demo
+ hierarchical-stopwatch
+ hierarchical-stopwatch-demo
diff --git a/template-placeholder-demo/pom.xml b/template-placeholder-demo/pom.xml
index 78b4a3e..3159199 100644
--- a/template-placeholder-demo/pom.xml
+++ b/template-placeholder-demo/pom.xml
@@ -5,7 +5,7 @@
4.0.0
software.xdev
- template-placeholder-demo
+ hierarchical-stopwatch-demo
1.0.0-SNAPSHOT
jar
@@ -27,7 +27,7 @@
software.xdev
- template-placeholder
+ hierarchical-stopwatch
${project.version}
diff --git a/template-placeholder/pom.xml b/template-placeholder/pom.xml
index b72a766..db9e62c 100644
--- a/template-placeholder/pom.xml
+++ b/template-placeholder/pom.xml
@@ -5,17 +5,17 @@
4.0.0
software.xdev
- template-placeholder
+ hierarchical-stopwatch
1.0.0-SNAPSHOT
jar
- template-placeholder
- template-placeholder
- https://github.com/xdev-software/template-placeholder
+ hierarchical-stopwatch
+ hierarchical-stopwatch
+ https://github.com/xdev-software/hierarchical-stopwatch
- https://github.com/xdev-software/template-placeholder
- scm:git:https://github.com/xdev-software/template-placeholder.git
+ https://github.com/xdev-software/hierarchical-stopwatch
+ scm:git:https://github.com/xdev-software/hierarchical-stopwatch.git
2023
From 499b19fe47090b7465965d0aadcbc928868d3183 Mon Sep 17 00:00:00 2001
From: AB
Date: Tue, 23 Apr 2024 10:29:58 +0200
Subject: [PATCH 18/27] Rename II
---
.../pom.xml | 0
{template-placeholder => hierarchical-stopwatch}/pom.xml | 0
2 files changed, 0 insertions(+), 0 deletions(-)
rename {template-placeholder-demo => hierarchical-stopwatch-demo}/pom.xml (100%)
rename {template-placeholder => hierarchical-stopwatch}/pom.xml (100%)
diff --git a/template-placeholder-demo/pom.xml b/hierarchical-stopwatch-demo/pom.xml
similarity index 100%
rename from template-placeholder-demo/pom.xml
rename to hierarchical-stopwatch-demo/pom.xml
diff --git a/template-placeholder/pom.xml b/hierarchical-stopwatch/pom.xml
similarity index 100%
rename from template-placeholder/pom.xml
rename to hierarchical-stopwatch/pom.xml
From b5ff019cf05b53cd0697267b0a6297274db7ab09 Mon Sep 17 00:00:00 2001
From: AB
Date: Wed, 12 Jun 2024 09:36:06 +0200
Subject: [PATCH 19/27] Fill in template
---
.github/ISSUE_TEMPLATE/bug_report.yml | 4 ++--
.github/ISSUE_TEMPLATE/enhancement.yml | 2 +-
.github/ISSUE_TEMPLATE/question.yml | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
index 68299d5..37a4d8c 100644
--- a/.github/ISSUE_TEMPLATE/bug_report.yml
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -14,9 +14,9 @@ body:
attributes:
label: "Checklist"
options:
- - label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/template-placeholder/releases/latest)"
+ - label: "I am able to reproduce the bug with the [latest version](https://github.com/xdev-software/hierarchical-stopwatch/releases/latest)"
required: true
- - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
+ - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/hierarchical-stopwatch/issues) or [closed](https://github.com/xdev-software/hierarchical-stopwatch/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the bug report will be dismissed otherwise."
required: true
diff --git a/.github/ISSUE_TEMPLATE/enhancement.yml b/.github/ISSUE_TEMPLATE/enhancement.yml
index 7523129..2949bb3 100644
--- a/.github/ISSUE_TEMPLATE/enhancement.yml
+++ b/.github/ISSUE_TEMPLATE/enhancement.yml
@@ -12,7 +12,7 @@ body:
attributes:
label: "Checklist"
options:
- - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
+ - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/hierarchical-stopwatch/issues) or [closed](https://github.com/xdev-software/hierarchical-stopwatch/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the feature request will be dismissed otherwise."
required: true
diff --git a/.github/ISSUE_TEMPLATE/question.yml b/.github/ISSUE_TEMPLATE/question.yml
index 6ecd6ad..e6c1707 100644
--- a/.github/ISSUE_TEMPLATE/question.yml
+++ b/.github/ISSUE_TEMPLATE/question.yml
@@ -12,7 +12,7 @@ body:
attributes:
label: "Checklist"
options:
- - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/template-placeholder/issues) or [closed](https://github.com/xdev-software/template-placeholder/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
+ - label: "I made sure that there are *no existing issues* - [open](https://github.com/xdev-software/hierarchical-stopwatch/issues) or [closed](https://github.com/xdev-software/hierarchical-stopwatch/issues?q=is%3Aissue+is%3Aclosed) - which I could contribute my information to."
required: true
- label: "I have taken the time to fill in all the required details. I understand that the question will be dismissed otherwise."
required: true
From 86d98b301787cc2469633b06e87610103b1dd7ea Mon Sep 17 00:00:00 2001
From: AB
Date: Fri, 30 Aug 2024 08:47:08 +0200
Subject: [PATCH 20/27] Fix pmd
---
.../xdev/time/HierarchicalStopWatch.java | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatch.java b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatch.java
index d99c508..3a56574 100644
--- a/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatch.java
+++ b/hierarchical-stopwatch/src/main/java/software/xdev/time/HierarchicalStopWatch.java
@@ -181,14 +181,14 @@ public String getPrettyPrinted()
return "";
}
- final StringBuilder sb = new StringBuilder();
- sb.append(System.lineSeparator());
- sb.append("-------------------------------");
- sb.append(System.lineSeparator());
- sb.append("Root Parent Task");
- sb.append(System.lineSeparator());
- sb.append("-------------------------------");
- sb.append(System.lineSeparator());
+ final StringBuilder sb = new StringBuilder(100);
+ sb.append(System.lineSeparator())
+ .append("-------------------------------")
+ .append(System.lineSeparator())
+ .append("Root Parent Task")
+ .append(System.lineSeparator())
+ .append("-------------------------------")
+ .append(System.lineSeparator());
final long rootNanos = this.sw.getNanoTime();
From b0a1341403b31a93132ac7561b51e99284c6b94e Mon Sep 17 00:00:00 2001
From: AB
Date: Fri, 30 Aug 2024 08:50:08 +0200
Subject: [PATCH 21/27] Update CHANGELOG.md
---
CHANGELOG.md | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index f31489f..36e5456 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,7 @@
+# 1.1.1
+* Minor performance improvements
+* Update dependencies
+
# 1.1.0
* Consolidated ``AutoCloseable`` into ``HierarchicalStopWatch``
From d859937b5ca01ccfcb85b37f65600da76713035d Mon Sep 17 00:00:00 2001
From: AB
Date: Fri, 30 Aug 2024 08:52:13 +0200
Subject: [PATCH 22/27] Fix renovate
---
renovate.json5 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/renovate.json5 b/renovate.json5
index 2874d45..92e0f9e 100644
--- a/renovate.json5
+++ b/renovate.json5
@@ -4,7 +4,7 @@
"packageRules": [
{
"description": "Ignore project internal dependencies",
- "packagePattern": "^software.xdev:template-placeholder",
+ "packagePattern": "^software.xdev:hierarchical-stopwatchch",
"datasources": [
"maven"
],
From 40d67bed10e55ec31398638c6160b0b5c755fd88 Mon Sep 17 00:00:00 2001
From: AB
Date: Fri, 30 Aug 2024 08:55:20 +0200
Subject: [PATCH 23/27] Fix typo
---
renovate.json5 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/renovate.json5 b/renovate.json5
index 92e0f9e..487db4e 100644
--- a/renovate.json5
+++ b/renovate.json5
@@ -4,7 +4,7 @@
"packageRules": [
{
"description": "Ignore project internal dependencies",
- "packagePattern": "^software.xdev:hierarchical-stopwatchch",
+ "packagePattern": "^software.xdev:hierarchical-stopwatch",
"datasources": [
"maven"
],
From c5543b83a470e24732fe5996bd2360b3a45413b8 Mon Sep 17 00:00:00 2001
From: XDEV Renovate Bot
Date: Fri, 30 Aug 2024 06:56:23 +0000
Subject: [PATCH 24/27] Update dependency org.apache.commons:commons-lang3 to
v3.17.0
---
hierarchical-stopwatch/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hierarchical-stopwatch/pom.xml b/hierarchical-stopwatch/pom.xml
index f674c08..57fdf53 100644
--- a/hierarchical-stopwatch/pom.xml
+++ b/hierarchical-stopwatch/pom.xml
@@ -88,7 +88,7 @@
org.apache.commons
commons-lang3
- 3.14.0
+ 3.17.0
From 71674142a120b4f59302b68da6d90b1aadea4299 Mon Sep 17 00:00:00 2001
From: GitHub Actions
Date: Fri, 30 Aug 2024 06:58:47 +0000
Subject: [PATCH 25/27] Release 1.1.1
---
hierarchical-stopwatch-demo/pom.xml | 4 ++--
hierarchical-stopwatch/pom.xml | 2 +-
pom.xml | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hierarchical-stopwatch-demo/pom.xml b/hierarchical-stopwatch-demo/pom.xml
index 00eb4fc..562fbb6 100644
--- a/hierarchical-stopwatch-demo/pom.xml
+++ b/hierarchical-stopwatch-demo/pom.xml
@@ -7,11 +7,11 @@
software.xdev
hierarchical-stopwatch-root
- 1.1.1-SNAPSHOT
+ 1.1.1
hierarchical-stopwatch-demo
- 1.1.1-SNAPSHOT
+ 1.1.1
jar
diff --git a/hierarchical-stopwatch/pom.xml b/hierarchical-stopwatch/pom.xml
index 57fdf53..02245f4 100644
--- a/hierarchical-stopwatch/pom.xml
+++ b/hierarchical-stopwatch/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch
- 1.1.1-SNAPSHOT
+ 1.1.1
jar
hierarchical-stopwatch
diff --git a/pom.xml b/pom.xml
index 6ebe215..f2ae14c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch-root
- 1.1.1-SNAPSHOT
+ 1.1.1
pom
From ad7fbc3a88994a4ce4c39722c698eee576aa6fdf Mon Sep 17 00:00:00 2001
From: AB
Date: Fri, 30 Aug 2024 08:59:40 +0200
Subject: [PATCH 26/27] Fix sonar warning for demo
---
.../src/main/java/software/xdev/Application.java | 1 +
1 file changed, 1 insertion(+)
diff --git a/hierarchical-stopwatch-demo/src/main/java/software/xdev/Application.java b/hierarchical-stopwatch-demo/src/main/java/software/xdev/Application.java
index f97ee6a..b1d8a22 100644
--- a/hierarchical-stopwatch-demo/src/main/java/software/xdev/Application.java
+++ b/hierarchical-stopwatch-demo/src/main/java/software/xdev/Application.java
@@ -10,6 +10,7 @@
public final class Application
{
+ @SuppressWarnings("java:S106")
public static void main(final String[] args)
{
try(final HierarchicalStopWatch dummySw = HierarchicalLoggingStopWatch.createStarted(
From 3de8b0e846a17d9b75424a2c2f424d364a3bec44 Mon Sep 17 00:00:00 2001
From: GitHub Actions
Date: Fri, 30 Aug 2024 07:01:03 +0000
Subject: [PATCH 27/27] Preparing for next development iteration
---
hierarchical-stopwatch-demo/pom.xml | 4 ++--
hierarchical-stopwatch/pom.xml | 2 +-
pom.xml | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/hierarchical-stopwatch-demo/pom.xml b/hierarchical-stopwatch-demo/pom.xml
index 562fbb6..493b84b 100644
--- a/hierarchical-stopwatch-demo/pom.xml
+++ b/hierarchical-stopwatch-demo/pom.xml
@@ -7,11 +7,11 @@
software.xdev
hierarchical-stopwatch-root
- 1.1.1
+ 1.1.2-SNAPSHOT
hierarchical-stopwatch-demo
- 1.1.1
+ 1.1.2-SNAPSHOT
jar
diff --git a/hierarchical-stopwatch/pom.xml b/hierarchical-stopwatch/pom.xml
index 02245f4..e9309ac 100644
--- a/hierarchical-stopwatch/pom.xml
+++ b/hierarchical-stopwatch/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch
- 1.1.1
+ 1.1.2-SNAPSHOT
jar
hierarchical-stopwatch
diff --git a/pom.xml b/pom.xml
index f2ae14c..df3be9e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -6,7 +6,7 @@
software.xdev
hierarchical-stopwatch-root
- 1.1.1
+ 1.1.2-SNAPSHOT
pom