Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import std.stdio;
- import std.string;
- import std.array;
- import std.algorithm : splitter;
- import std.typecons : tuple, Tuple;
- import std.conv : to;
- void read_log(string filename) {
- File file = File(filename, "r");
- Tuple!(char[], int, char[])[] npushed;
- Tuple!(int, char[], int, bool, bool)[] pushed;
- foreach (line; file.byLine) {
- if (line.indexOf("SOC_NOT_PUSHED") != -1) {
- auto tarr = line.split();
- npushed ~= tuple(tarr[2] ~ tarr[3], to!int(tarr[$ - 1]), tarr[$ - 2]);
- continue;
- }
- if (line.indexOf("SYNC_PUSH:") != -1) {
- auto rel = line.split("SYNC_PUSH:")[1].strip();
- auto att = rel.split(" at ");
- auto ina = att[1].split(" in ");
- auto msa = ina[1].split(" ms ");
- pushed ~= tuple(to!int(att[0]), ina[0], to!int(msa[0]),
- msa[1].indexOf("PA-SOC_POP") != -1, msa[1].indexOf("CU-SOC_POP") != -1);
- }
- }
- // Doing more stuff with these arrays later. For now, just printing lengths
- writeln(npushed.length);
- writeln(pushed.length);
- }
Add Comment
Please, Sign In to add comment