Add the protocol-comparison module
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package com.ankurm.protocols;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* Deterministic quote generation, shared by all three protocol adapters.
|
||||
*
|
||||
* <p>Deliberately cheap and deliberately allocation-free apart from the record: a benchmark of
|
||||
* three transports must not spend its time in the thing behind them.
|
||||
*/
|
||||
@Component
|
||||
public class QuoteSource {
|
||||
|
||||
public Quote at(String symbol, long seq) {
|
||||
double base = 100.0 + (seq % 97) * 0.01;
|
||||
Instant now = Instant.now();
|
||||
return new Quote(symbol, seq, base, base + 0.02,
|
||||
now.getEpochSecond() * 1_000_000L + now.getNano() / 1_000L);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user