Skip to content

Commit

Permalink
PP-12600: Code improvement and benchmark documentation (#1205)
Browse files Browse the repository at this point in the history
  • Loading branch information
oswaldquek authored May 7, 2024
1 parent 6b985bd commit bf01700
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/uk/gov/pay/card/resources/CardIdResource.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ public Response cardInformation(@NotNull @Valid CardInformationRequest cardInfor
.build();
}

private Optional<Long> getCardNumber(String prefix) {
private Optional<Long> getCardNumber(String cardNumber) {
try {
return Optional.of(Long.valueOf(prefix));
return Optional.of(Long.valueOf(cardNumber));
} catch (NumberFormatException e) {
logger.info("Received card number that cannot be parsed into long");
return Optional.empty();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,18 @@
* - Change the name of the file to load in this benchmark (in the setup()) method.
* - You would have to replace the existing test card prefixes with some new prefixes.
* - And then run the benchmark.
*
* The Benchmark outputs something like the following:
*
* Benchmark (cardIdPrefix) Mode Cnt Score Error Units
* RangeSetCardInformationStoreBenchmark.runBenchmark 511226661120000000 avgt 20 0.145 ± 0.001 us/op
* RangeSetCardInformationStoreBenchmark.runBenchmark 511226661130000000 avgt 20 0.142 ± 0.004 us/op
* RangeSetCardInformationStoreBenchmark.runBenchmark 511226661140000000 avgt 20 0.146 ± 0.002 us/op
* etc
*
* This means the test card 511226661120000000 took 0.145 microseconds to run on average over 20 iterations.
* Assuming that the results are normally distributed, one would expect that the "true" execution time for
* that method has a 99.9% probability to be somewhere between 0.145± 0.001 microseconds.
*/
@State(Scope.Benchmark)
public class RangeSetCardInformationStoreBenchmark {
Expand Down

0 comments on commit bf01700

Please sign in to comment.