spring-profiler

Enables simple profiling of methods or code-snippets in spring-projects

License

License

Categories

Categories

IDE Development Tools
GroupId

GroupId

com.avides.spring
ArtifactId

ArtifactId

spring-profiler
Last Version

Last Version

0.1.0.RELEASE
Release Date

Release Date

Type

Type

jar
Description

Description

spring-profiler
Enables simple profiling of methods or code-snippets in spring-projects
Project URL

Project URL

https://github.com/avides/spring-profiler
Project Organization

Project Organization

AVIDES Media AG
Source Code Management

Source Code Management

https://github.com/avides/spring-profiler

Download spring-profiler

How to add to project

<!-- https://jarcasting.com/artifacts/com.avides.spring/spring-profiler/ -->
<dependency>
    <groupId>com.avides.spring</groupId>
    <artifactId>spring-profiler</artifactId>
    <version>0.1.0.RELEASE</version>
</dependency>
// https://jarcasting.com/artifacts/com.avides.spring/spring-profiler/
implementation 'com.avides.spring:spring-profiler:0.1.0.RELEASE'
// https://jarcasting.com/artifacts/com.avides.spring/spring-profiler/
implementation ("com.avides.spring:spring-profiler:0.1.0.RELEASE")
'com.avides.spring:spring-profiler:jar:0.1.0.RELEASE'
<dependency org="com.avides.spring" name="spring-profiler" rev="0.1.0.RELEASE">
  <artifact name="spring-profiler" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.avides.spring', module='spring-profiler', version='0.1.0.RELEASE')
)
libraryDependencies += "com.avides.spring" % "spring-profiler" % "0.1.0.RELEASE"
[com.avides.spring/spring-profiler "0.1.0.RELEASE"]

Dependencies

compile (4)

Group / Artifact Type Version
org.springframework : spring-context jar 5.0.1.RELEASE
org.slf4j : slf4j-api jar 1.7.25
org.aspectj : aspectjrt jar 1.8.13
org.aspectj : aspectjweaver jar 1.8.13

test (6)

Group / Artifact Type Version
org.slf4j : slf4j-simple jar 1.7.25
junit : junit jar 4.12
org.easymock : easymock jar 3.5.1
org.powermock : powermock-module-junit4 jar 1.7.3
org.powermock : powermock-api-easymock jar 1.7.3
org.assertj : assertj-core jar 3.8.0

Project Modules

There are no modules declared in this project.

spring-profiler

Maven Central Codacy Badge Coverage Status Build Status

Maven

<dependency>
    <groupId>com.avides.spring</groupId>
    <artifactId>spring-profiler</artifactId>
    <version>0.1.0.RELEASE</version>
</dependency>

Simple example

Profiler profiler = Profiler.startProfiling("anyIdentifier");
Thread.sleep(100);
// or any other code you want to profile
profiler.stop();

This will give you a log-message (debug-level) that looks similar to this:

execution time for anyIdentifier: 102ms

After stopping the profiler, you have access to some execution details, for example the exact execution-time by calling profiler.getDurationMillis()

Example with explicit given ProfilingHandler and allowedMillis

Profiler profiler = Profiler.startProfiling("anyIdentifier", new SysoutProfilingHandler());
Thread.sleep(100);
// or any other code you want to profile
profiler.stop(50);

This will give you an output to the System.out that looks similar to this:

WARNING: execution time for anyIdentifier: 102ms (allowed: 50ms)

If you do not specify a ProfilingHandler, a LoggingProfilingHandler is used as default (see example above). If you do so and the allowed time is exceeded, the logging-level switches to warning.

Of course, you can give your own ProfilingHandler-implementation (and even several at once) that meets your needs

Profiling of methods simply by annotation (only supported in a spring-application)

@Component
public class anyClass
{
    @Profiling
    public void anyMethod()
    {
        Thread.sleep(100);
        // or any other code you want to profile
    }
}

To get this working, simply add an @EnableProfiling-annotation at any of your configuration-classes (or the Application-class). After executing the method "anyMethod", it will give you a log-message (debug-level) that looks similar to this:

execution time for method anyClass.anyMethod(): 102ms

Explicit ProfilingHandlers and allowedMillis (explained in example above) can be set via the @Profiling-annotation-attributes (which also are well documented in javadoc)

com.avides.spring

AVIDES Media AG

E-Commerce Solutions

Versions

Version
0.1.0.RELEASE
0.0.11-RELEASE
0.0.10-RELEASE
0.0.9-RELEASE
0.0.8-RELEASE
0.0.7-RELEASE
0.0.6-RELEASE
0.0.5-RELEASE
0.0.4-RELEASE
0.0.3-RELEASE
0.0.2-RELEASE
0.0.1-RELEASE