Skip to content

Commit

Permalink
adding a null processor for timing
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljon committed May 27, 2022
1 parent f202ab4 commit 7274b61
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
25 changes: 25 additions & 0 deletions Modules/NullProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
namespace Ovation.FasterQC.Net
{
public class NullProcessor : IQcModule
{
private ulong sequenceCount;

public string Name => "nullProcessor";

public string Description => "Runs a minimal processor";

public bool IsEnabledForAll => false;

public object Data => sequenceCount;

public void ProcessSequence(Sequence sequence)
{
sequenceCount++;
}

public void Reset()
{
sequenceCount = 0;
}
}
}
12 changes: 11 additions & 1 deletion Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ private static void Main(string[] args)
config.AutoHelp = true;
config.AutoVersion = true;
config.CaseInsensitiveEnumValues = true;
config.EnableDashDash = false;
}
);

Expand Down Expand Up @@ -76,6 +77,8 @@ private void Run()
On(Settings.ShowProgress, () => progressBar = new TimedSequenceProgressBar(sequenceReader));
On(Settings.Verbose, () => Console.Error.WriteLine($"Processing {Settings.InputFilename}..."));

var started = DateTime.UtcNow;

while (sequenceReader.SequencesRead < Settings.ReadLimit && sequenceReader.ReadSequence(out Sequence? sequence))
{
ArgumentNullException.ThrowIfNull(sequence);
Expand All @@ -95,14 +98,21 @@ private void Run()
});
}

var ended = DateTime.UtcNow;
var elapsed = ended.Subtract(started).TotalSeconds;

Dictionary<string, object>? results = new()
{
["_metadata"] = new
{
_modules = Settings.ModuleNames,
_inputFilename = Settings.InputFilename,
_outputFilename = string.IsNullOrWhiteSpace(Settings.OutputFilename) ? "STDOUT" : Settings.OutputFilename,
_sequences = sequenceReader.SequencesRead
_sequences = sequenceReader.SequencesRead,
_started = started,
_ended = ended,
_elapsed = elapsed,
_rate = (double)sequenceReader.SequencesRead / (double)elapsed
}
};

Expand Down

0 comments on commit 7274b61

Please sign in to comment.