mirror of
https://github.com/vacp2p/mix.git
synced 2026-01-09 03:17:54 -05:00
fix: use times instead of chronos for benchmark logs
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import chronicles, chronos, sequtils, strutils, os, results
|
import chronicles, chronos, sequtils, strutils, os, results
|
||||||
import std/[strformat, sysrand, tables], metrics
|
import std/[strformat, sysrand, tables], metrics, times
|
||||||
import
|
import
|
||||||
./[
|
./[
|
||||||
config, curve25519, fragmentation, mix_message, mix_node, sphinx, serialization,
|
config, curve25519, fragmentation, mix_message, mix_node, sphinx, serialization,
|
||||||
@@ -44,14 +44,14 @@ type MixProtocol* = ref object of LPProtocol
|
|||||||
proc benchmarkLog*(
|
proc benchmarkLog*(
|
||||||
eventName: static[string],
|
eventName: static[string],
|
||||||
myPeerId: PeerId,
|
myPeerId: PeerId,
|
||||||
startTime: Moment,
|
startTime: Time,
|
||||||
msgId: uint64,
|
msgId: uint64,
|
||||||
orig: uint64,
|
orig: uint64,
|
||||||
fromPeerId: Opt[PeerId],
|
fromPeerId: Opt[PeerId],
|
||||||
toPeerId: Opt[PeerId],
|
toPeerId: Opt[PeerId],
|
||||||
) =
|
) =
|
||||||
let endTime = Moment.now()
|
let endTime = getTime()
|
||||||
let procDelay = (endTime - startTime).milliseconds()
|
let procDelay = (endTime - startTime).inMilliseconds()
|
||||||
let fromPeerId =
|
let fromPeerId =
|
||||||
if fromPeerId.isNone:
|
if fromPeerId.isNone:
|
||||||
"None"
|
"None"
|
||||||
@@ -131,7 +131,7 @@ proc handleMixNodeConnection(
|
|||||||
error "Failed to close incoming stream: ", err = e.msg
|
error "Failed to close incoming stream: ", err = e.msg
|
||||||
|
|
||||||
when defined(enable_mix_benchmarks):
|
when defined(enable_mix_benchmarks):
|
||||||
let startTime = Moment.now()
|
let startTime = getTime()
|
||||||
|
|
||||||
if metadata.len == 0:
|
if metadata.len == 0:
|
||||||
mix_messages_error.inc(labelValues = ["Intermediate/Exit", "NO_DATA"])
|
mix_messages_error.inc(labelValues = ["Intermediate/Exit", "NO_DATA"])
|
||||||
@@ -280,7 +280,7 @@ proc handleMixNodeConnection(
|
|||||||
trace "# Intermediate: ", multiAddr = multiAddr
|
trace "# Intermediate: ", multiAddr = multiAddr
|
||||||
# Add delay
|
# Add delay
|
||||||
mix_messages_recvd.inc(labelValues = ["Intermediate"])
|
mix_messages_recvd.inc(labelValues = ["Intermediate"])
|
||||||
await sleepAsync(milliseconds(processedSP.delayMs))
|
await sleepAsync(chronos.milliseconds(processedSP.delayMs))
|
||||||
|
|
||||||
# Forward to next hop
|
# Forward to next hop
|
||||||
let nextHopBytes = getHop(processedSP.nextHop)
|
let nextHopBytes = getHop(processedSP.nextHop)
|
||||||
@@ -459,7 +459,7 @@ type SendPacketType* = enum
|
|||||||
type SendPacketConfig = object
|
type SendPacketConfig = object
|
||||||
logType: SendPacketType
|
logType: SendPacketType
|
||||||
when defined(enable_mix_benchmarks):
|
when defined(enable_mix_benchmarks):
|
||||||
startTime: Moment
|
startTime: Time
|
||||||
orig: uint64
|
orig: uint64
|
||||||
msgId: uint64
|
msgId: uint64
|
||||||
origAndMsgId: seq[byte]
|
origAndMsgId: seq[byte]
|
||||||
@@ -562,7 +562,7 @@ proc anonymizeLocalProtocolSend*(
|
|||||||
) {.async.} =
|
) {.async.} =
|
||||||
var config = SendPacketConfig(logType: Entry)
|
var config = SendPacketConfig(logType: Entry)
|
||||||
when defined(enable_mix_benchmarks):
|
when defined(enable_mix_benchmarks):
|
||||||
config.startTime = Moment.now()
|
config.startTime = getTime()
|
||||||
|
|
||||||
let (multiAddr, _, _, _, _) = getMixNodeInfo(mixProto.mixNodeInfo)
|
let (multiAddr, _, _, _, _) = getMixNodeInfo(mixProto.mixNodeInfo)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user