-
Notifications
You must be signed in to change notification settings - Fork 2
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 #99 from Friendly-neighborhood-development/benchma…
…rking Benchmarked annotation deployed
- Loading branch information
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
server/games-service/src/main/java/com/fnd/games_store/games/annotations/Benchmarked.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,12 @@ | ||
package com.fnd.games_store.games.annotations; | ||
|
||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.METHOD) | ||
public @interface Benchmarked { | ||
} |
32 changes: 32 additions & 0 deletions
32
server/games-service/src/main/java/com/fnd/games_store/games/aspects/Benchmarking.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 @@ | ||
package com.fnd.games_store.games.aspects; | ||
|
||
import lombok.extern.slf4j.Slf4j; | ||
import org.aspectj.lang.ProceedingJoinPoint; | ||
import org.aspectj.lang.annotation.Around; | ||
import org.aspectj.lang.annotation.Aspect; | ||
import org.springframework.stereotype.Component; | ||
|
||
import java.time.Duration; | ||
import java.time.Instant; | ||
|
||
@Component | ||
@Aspect | ||
@Slf4j | ||
public class Benchmarking { | ||
|
||
|
||
@Around("@annotation(com.fnd.games_store.games.annotations.Benchmarked)") | ||
public Object performTImeMeasure(ProceedingJoinPoint joinPoint) throws Throwable { | ||
|
||
Instant startTime = Instant.now(); | ||
|
||
Object proceed = joinPoint.proceed(); | ||
|
||
Instant endTime = Instant.now(); | ||
|
||
log.info(Duration.between(endTime,startTime).toString()); | ||
|
||
return proceed; | ||
} | ||
|
||
} |
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