-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from hohwille/master
improve maven-profier
- Loading branch information
Showing
19 changed files
with
583 additions
and
113 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,12 @@ | ||
.* | ||
!.github | ||
!.gitignore | ||
!.mvn | ||
*.bak | ||
*.log | ||
*.diff | ||
*.patch | ||
*.iml | ||
target | ||
.project | ||
.classpath | ||
.settings | ||
release.properties | ||
release.properties | ||
|
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
38 changes: 38 additions & 0 deletions
38
src/main/java/io/tesla/lifecycle/profiler/AbstractProfile.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright (c) 2012 to original author or authors | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package io.tesla.lifecycle.profiler; | ||
|
||
public abstract class AbstractProfile implements Profile { | ||
|
||
protected long elapsedTime; | ||
|
||
protected AbstractProfile() { | ||
super(); | ||
} | ||
|
||
/** | ||
* @param elapsedTime the new value of {@link #getElapsedTime()}. | ||
*/ | ||
public void setElapsedTime(long elapsedTime) { | ||
this.elapsedTime = elapsedTime; | ||
} | ||
|
||
/** | ||
* @param millis the milliseconds to add to {@link #getElapsedTime() elapsed time}. | ||
*/ | ||
public void addElapsedTime(long millis) { | ||
|
||
this.elapsedTime += millis; | ||
} | ||
|
||
@Override | ||
public long getElapsedTime() { | ||
return elapsedTime; | ||
} | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/io/tesla/lifecycle/profiler/AbstractTimerProfile.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright (c) 2012 to original author or authors | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package io.tesla.lifecycle.profiler; | ||
|
||
import io.tesla.lifecycle.profiler.internal.DefaultTimer; | ||
|
||
public abstract class AbstractTimerProfile extends AbstractProfile { | ||
|
||
protected final Timer timer; | ||
|
||
protected AbstractTimerProfile() { | ||
this.timer = new DefaultTimer(); | ||
} | ||
|
||
public void stop() { | ||
timer.stop(); | ||
} | ||
|
||
@Override | ||
public long getElapsedTime() { | ||
if(elapsedTime != 0) { | ||
return elapsedTime; | ||
} | ||
return timer.getElapsedTime(); | ||
} | ||
|
||
} |
75 changes: 75 additions & 0 deletions
75
src/main/java/io/tesla/lifecycle/profiler/AggregationProfile.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* Copyright (c) 2012 to original author or authors | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package io.tesla.lifecycle.profiler; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class AggregationProfile extends AbstractProfile { | ||
|
||
private final String name; | ||
|
||
private final Map<String, AggregationProfile> childMap; | ||
|
||
private final List<AggregationProfile> children; | ||
|
||
public AggregationProfile() { | ||
this("all"); | ||
} | ||
|
||
public AggregationProfile(String name) { | ||
super(); | ||
this.name = name; | ||
this.childMap = new HashMap<>(); | ||
this.children = new ArrayList<>(); | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
|
||
return this.name; | ||
} | ||
|
||
@Override | ||
public long getElapsedTime() { | ||
|
||
long millis = this.elapsedTime; | ||
if (millis == 0) { | ||
for (AggregationProfile child : this.children) { | ||
millis += child.getElapsedTime(); | ||
} | ||
} | ||
return millis; | ||
} | ||
|
||
public AggregationProfile getChild(String name) { | ||
|
||
return this.childMap.get(name); | ||
} | ||
|
||
public AggregationProfile getOrCreateChild(String name) { | ||
|
||
return this.childMap.computeIfAbsent(name, this::newAggregationProfile); | ||
} | ||
|
||
private AggregationProfile newAggregationProfile(String name) { | ||
|
||
AggregationProfile profile = new AggregationProfile(name); | ||
this.children.add(profile); | ||
return profile; | ||
} | ||
|
||
@Override | ||
public Collection<? extends Profile> getChildren() { | ||
|
||
return this.children; | ||
} | ||
} |
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
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
Oops, something went wrong.