/// <inheritdoc /> public void FinishAlgorithm(Snapshot snapshot, AlgorithmType algorithmType) { AlgorithmKey key = new AlgorithmKey(algorithmType, snapshot); AlgorithmEntry entry; if (algorithms.TryGetValue(key, out entry)) { if (numberOfActiveAlgorithms > 0) { numberOfActiveAlgorithms--; if (numberOfActiveAlgorithms == 0) { algorithmStopwatch.Stop(); TotalAlgorithmTime = algorithmStopwatch.Elapsed.TotalMilliseconds; } } entry.StopAlgorithm(); AlgorithmAggregationEntry aggregation; if (!algorithmResults.TryGetValue(algorithmType, out aggregation)) { aggregation = new AlgorithmAggregationEntry(algorithmType); algorithmResults.Add(algorithmType, aggregation); } aggregation.AlgorithmStopped(entry); algorithms.Remove(key); NumberOfAlgorithms++; } }
/// <inheritdoc /> public void StartAlgorithm(Snapshot snapshot, AlgorithmType algorithmType) { AlgorithmKey key = new AlgorithmKey(algorithmType, snapshot); if (!algorithms.ContainsKey(key)) { TransactionEntry transaction; if (!transactions.TryGetValue(snapshot, out transaction)) { transaction = null; } AlgorithmEntry entry = AlgorithmEntry.CreateAndStartAlgorithm(algorithmType, transaction); algorithms.Add(key, entry); if (numberOfActiveAlgorithms == 0) { algorithmStopwatch.Start(); } numberOfActiveAlgorithms++; } }
public override bool Equals(object obj) { AlgorithmKey key = obj as AlgorithmKey; if (key == null) { return(false); } if (algorithmType != key.algorithmType) { return(false); } if (snapshot != null) { return(snapshot.Equals(key.snapshot)); } else { return(key.snapshot == null); } }