Timer Ninja mascot — a ninja sloth
Open Source · Java Library

Measure Java Code Execution Time
with a Single Annotation

Track code execution time in Java effortlessly. Get a full call hierarchy with timing & arguments — no heavy tracing frameworks required.

Latest io.github.thanglequoc:timer-ninja:1.3.0
Why Timer Ninja?

Performance Tracking,
Without the Pain

Full method timing with call hierarchy & argument details — without the weight of a distributed tracing framework.

🎯

One Annotation

Replace 6 lines of timestamp boilerplate with @TimerNinjaTracker. That's it.

🌳

Visual Call Tree + Args

See nested method calls as a clear, indented hierarchy — with full argument values. Instantly pinpoint what was called and with which data.

🧩

Block Tracking

Measure arbitrary code blocks with TimerNinjaBlock.measure() — no need to extract separate methods.

⚠️

Smart Thresholds

Only surface slow operations. Set a threshold and Timer Ninja filters the noise automatically.

🪶

Zero Dependencies

Just AspectJ + SLF4J. No framework lock-in. Works with Spring Boot, plain Java, or anything in between.

No Heavy Frameworks

Skip the complexity of OpenTelemetry, Zipkin, or Micrometer. Timer Ninja gives you actionable timing insights with zero infrastructure overhead.

Before & After

Stop Timing Methods
The Hard Way

See how Timer Ninja eliminates manual timestamp boilerplate.

Traditional Approach
long before = System.currentTimeMillis();
doSomethingInteresting();
long after = System.currentTimeMillis();
System.out.println(
  "Execution time (ms): " + (after - before)
);
✔️ Timer Ninja
@TimerNinjaTracker
public String doSomethingInteresting() {
    // Your business logic — that's it!
}
6 lines of boilerplate 1 annotation
See It In Action

Beautiful Trace Output

Timer Ninja prints a visual call tree showing the full execution hierarchy, timing, and arguments.

Timer Ninja Trace Output
Timer Ninja trace context id: 851ac23b-2669-4883-8c97-032b8fd2d45c Trace timestamp: 2023-04-03T07:16:48.491Z {===== Start of trace context id: 851ac23b... =====} public void requestMoneyTransfer(...) - Args: [sourceUserId={1}, targetUserId={2}, amount={500}] - 1747 ms |-- public User findUser(int userId) - 105000 µs |-- public void processPayment(User user, int amount) - 770 ms |-- public boolean changeAmount(User user, int amount) - 306 ms |-- public void notify(User user) - 258 ms |-- private void notifyViaSMS(User user) - 53 ms |-- private void notifyViaEmail(User user) - 205 ms ¤ [Threshold Exceed !!: 200 ms] {====== End of trace context id: 851ac23b... ======}
Why Timer Ninja?

Heavy Tracing Frameworks
Are Overkill

Most apps don't need distributed tracing infrastructure just to answer “why is this method slow?”

🚨 Typical Tracing Framework
  • Install collector agent & backend (Jaeger/Zipkin)
  • Add SDK + multiple dependencies
  • Configure exporters, samplers, propagators
  • Manually create spans with Tracer API
  • Deploy & manage a separate tracing dashboard
  • Instrument each method individually
  • Arguments & context? Write custom attributes by hand
🧡 Timer Ninja
  • One dependency — add to Gradle or Maven
  • One annotation@TimerNinjaTracker
  • Auto call hierarchy — nested tree, zero config
  • Arguments includedincludeArgs = true
  • Threshold alerts — only see what's slow
  • No infrastructure — output goes to your existing logs
  • Works immediately — no dashboards to deploy
Complex infrastructure setup 1 annotation, instant insights
Quick Start

Get Started in 60 Seconds

Four simple steps to start tracking method execution time.

1

Add the Dependency

Add Timer Ninja from Maven Central to your project.

implementation 'io.github.thanglequoc:timer-ninja:1.3.0'
aspect 'io.github.thanglequoc:timer-ninja:1.3.0'
<dependency>
    <groupId>io.github.thanglequoc</groupId>
    <artifactId>timer-ninja</artifactId>
    <version>1.3.0</version>
</dependency>
2

Add AspectJ Plugin

Enable AspectJ compilation so annotations get woven.

plugins {
    id "io.freefair.aspectj.post-compile-weaving" version '9.1.0'
}
<plugin>
    <groupId>dev.aspectj</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.14.1</version>
    <configuration>
        <aspectLibraries>
            <aspectLibrary>
                <groupId>io.github.thanglequoc</groupId>
                <artifactId>timer-ninja</artifactId>
            </aspectLibrary>
        </aspectLibraries>
    </configuration>
</plugin>
3

Annotate Your Methods

Place @TimerNinjaTracker on any method or constructor.

@TimerNinjaTracker
public void processPayment(User user, int amount) {
    // Your business logic
}
4

Run & See the Trace 🐇

Execute your code — Timer Ninja automatically logs the execution trace.

Note: Timer Ninja uses SLF4J. Spring Boot projects work out of the box. For other projects without a logging provider, enable console output with TimerNinjaConfiguration.getInstance().toggleSystemOutLog(true).

public void processPayment(User user, int amount) - 770 ms
   |-- public boolean changeAmount(User user, int amount) - 306 ms
   |-- public void notify(User user) - 258 ms
Timer Ninja mascot

Ready to track them all?

Block tracking, custom thresholds, constructor tracking, and more — explore all features in the docs and start measuring Java method execution time the smart way.