wip: blockreceives to csv
This commit is contained in:
parent
672092b232
commit
02ca9db001
@ -2,6 +2,7 @@
|
|||||||
using Logging;
|
using Logging;
|
||||||
using OverwatchTranscript;
|
using OverwatchTranscript;
|
||||||
using TranscriptAnalysis;
|
using TranscriptAnalysis;
|
||||||
|
using TranscriptAnalysis.Receivers;
|
||||||
|
|
||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
@ -10,26 +11,75 @@ public static class Program
|
|||||||
public static void Main(string[] args)
|
public static void Main(string[] args)
|
||||||
{
|
{
|
||||||
Log("Transcript Analysis");
|
Log("Transcript Analysis");
|
||||||
if (!args.Any())
|
|
||||||
{
|
|
||||||
Log("Please pass a .owts file");
|
|
||||||
Console.ReadLine();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!File.Exists(args[0]))
|
var path1 = "d:\\Projects\\cs-codex-dist-tests\\Tests\\CodexTests\\bin\\Debug\\net8.0\\CodexTestLogs\\2024-10\\11\\08-31-52Z_SwarmTests\\";
|
||||||
|
var path2 = "d:\\Projects\\cs-codex-dist-tests\\Tests\\CodexTests\\bin\\Debug\\net8.0\\CodexTestLogs\\2024-10\\11\\09-28-29Z_SwarmTests\\";
|
||||||
|
var files1 = new[]
|
||||||
{
|
{
|
||||||
Log("File doesn't exist: " + args[0]);
|
(1, 3, "DetectBlockRetransmits[1,3]_swarm_retransmit.owts"),
|
||||||
Console.ReadLine();
|
(1, 5, "DetectBlockRetransmits[1,5]_swarm_retransmit.owts"),
|
||||||
return;
|
(1, 10, "DetectBlockRetransmits[1,10]_swarm_retransmit.owts"),
|
||||||
}
|
(1, 20, "DetectBlockRetransmits[1,20]_swarm_retransmit.owts"),
|
||||||
|
(5, 3, "DetectBlockRetransmits[5,3]_swarm_retransmit.owts"),
|
||||||
var reader = OpenReader(args[0]);
|
(5, 5, "DetectBlockRetransmits[5,5]_swarm_retransmit.owts"),
|
||||||
AppDomain.CurrentDomain.ProcessExit += (e, s) =>
|
(5, 10, "DetectBlockRetransmits[5,10]_swarm_retransmit.owts"),
|
||||||
|
(5, 20, "DetectBlockRetransmits[5,20]_swarm_retransmit.owts"),
|
||||||
|
(10, 5, "DetectBlockRetransmits[10,5]_swarm_retransmit.owts"),
|
||||||
|
(10, 10, "DetectBlockRetransmits[10,10]_swarm_retransmit.owts")
|
||||||
|
};
|
||||||
|
var files2 = new[]
|
||||||
{
|
{
|
||||||
CloseReader(reader);
|
(10, 20, "DetectBlockRetransmits[10,20]_swarm_retransmit.owts"),
|
||||||
|
(20, 3, "DetectBlockRetransmits[20,3]_swarm_retransmit.owts"),
|
||||||
|
(20, 5, "DetectBlockRetransmits[20,5]_swarm_retransmit.owts"),
|
||||||
|
(20, 10, "DetectBlockRetransmits[20,10]_swarm_retransmit.owts"),
|
||||||
|
(20, 20, "DetectBlockRetransmits[20,20]_swarm_retransmit.owts")
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var countLines = new List<int[]>();
|
||||||
|
|
||||||
|
foreach (var file in files1)
|
||||||
|
{
|
||||||
|
var path = Path.Combine(path1, file.Item3);
|
||||||
|
DuplicateBlocksReceived.Counts.Clear();
|
||||||
|
Run(path);
|
||||||
|
|
||||||
|
countLines.Add(new[] { file.Item1, file.Item2 }.Concat(DuplicateBlocksReceived.Counts).ToArray());
|
||||||
|
}
|
||||||
|
foreach (var file in files2)
|
||||||
|
{
|
||||||
|
var path = Path.Combine(path2, file.Item3);
|
||||||
|
DuplicateBlocksReceived.Counts.Clear();
|
||||||
|
Run(path);
|
||||||
|
|
||||||
|
countLines.Add(new[] { file.Item1, file.Item2 }.Concat(DuplicateBlocksReceived.Counts).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
var numColumns = countLines.Max(l => l.Length);
|
||||||
|
var header = new List<string>() { "filesize", "numNodes" };
|
||||||
|
for (var i = 0; i < numColumns - 2; i++) header.Add("recv" + (i + 1) + "x");
|
||||||
|
|
||||||
|
var lines = new List<string>() { string.Join(",", header.ToArray()) };
|
||||||
|
foreach (var count in countLines)
|
||||||
|
{
|
||||||
|
var tokens = new List<int>();
|
||||||
|
for (var i = 0; i < numColumns; i++)
|
||||||
|
{
|
||||||
|
if (i < count.Length) tokens.Add(count[i]);
|
||||||
|
else tokens.Add(0);
|
||||||
|
}
|
||||||
|
lines.Add(string.Join(",", tokens.Select(t => t.ToString()).ToArray()));
|
||||||
|
}
|
||||||
|
|
||||||
|
File.WriteAllLines("C:\\Users\\Ben\\Desktop\\blockretransmit.csv", lines.ToArray());
|
||||||
|
|
||||||
|
Log("Done.");
|
||||||
|
Console.ReadLine();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Run(string file)
|
||||||
|
{
|
||||||
|
var reader = OpenReader(file);
|
||||||
var header = reader.GetHeader<OverwatchCodexHeader>("cdx_h");
|
var header = reader.GetHeader<OverwatchCodexHeader>("cdx_h");
|
||||||
var receivers = new ReceiverSet(log, reader, header);
|
var receivers = new ReceiverSet(log, reader, header);
|
||||||
receivers.InitAll();
|
receivers.InitAll();
|
||||||
@ -40,8 +90,7 @@ public static class Program
|
|||||||
receivers.FinishAll();
|
receivers.FinishAll();
|
||||||
|
|
||||||
CloseReader(reader);
|
CloseReader(reader);
|
||||||
Log("Done.");
|
|
||||||
Console.ReadLine();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ITranscriptReader OpenReader(string filepath)
|
private static ITranscriptReader OpenReader(string filepath)
|
||||||
|
@ -5,6 +5,8 @@ namespace TranscriptAnalysis.Receivers
|
|||||||
{
|
{
|
||||||
public class DuplicateBlocksReceived : BaseReceiver<OverwatchCodexEvent>
|
public class DuplicateBlocksReceived : BaseReceiver<OverwatchCodexEvent>
|
||||||
{
|
{
|
||||||
|
public static List<int> Counts = new List<int>();
|
||||||
|
|
||||||
public override string Name => "BlocksReceived";
|
public override string Name => "BlocksReceived";
|
||||||
|
|
||||||
public override void Receive(ActivateEvent<OverwatchCodexEvent> @event)
|
public override void Receive(ActivateEvent<OverwatchCodexEvent> @event)
|
||||||
@ -31,13 +33,17 @@ namespace TranscriptAnalysis.Receivers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Counts.Any()) throw new Exception("Should be empty");
|
||||||
|
|
||||||
float t = totalReceived;
|
float t = totalReceived;
|
||||||
occurances.PrintContinous((i, count) =>
|
occurances.PrintContinous((i, count) =>
|
||||||
{
|
{
|
||||||
float n = count;
|
float n = count;
|
||||||
float p = 100.0f * (n / t);
|
float p = 100.0f * (n / t);
|
||||||
Log($"Block received {i} times = {count}x ({p}%)");
|
Log($"Block received {i} times = {count}x ({p}%)");
|
||||||
|
Counts.Add(count);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private int seen = 0;
|
private int seen = 0;
|
||||||
@ -46,6 +52,7 @@ namespace TranscriptAnalysis.Receivers
|
|||||||
private void Handle(OverwatchCodexEvent payload, BlockReceivedEvent blockReceived)
|
private void Handle(OverwatchCodexEvent payload, BlockReceivedEvent blockReceived)
|
||||||
{
|
{
|
||||||
var receiverPeerId = GetPeerId(payload.NodeIdentity);
|
var receiverPeerId = GetPeerId(payload.NodeIdentity);
|
||||||
|
if (receiverPeerId == null) return;
|
||||||
var blockAddress = blockReceived.BlockAddress;
|
var blockAddress = blockReceived.BlockAddress;
|
||||||
seen++;
|
seen++;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user