1
1
using System ;
2
+ using System . Collections . Generic ;
2
3
using System . Diagnostics ;
4
+ using System . Linq ;
5
+ using TopDownProteomics . Biochemistry ;
3
6
using TopDownProteomics . Chemistry ;
4
7
using TopDownProteomics . Tools ;
5
8
@@ -11,15 +14,16 @@ internal class Program
11
14
12
15
private static void Main ( string [ ] args )
13
16
{
14
- BenchmarkIsotopicEvelopeGeneration ( ) ;
17
+ //BenchmarkIsotopicEnvelopeGeneration();
18
+ BenchmarkChemicalFormulaAsKey ( ) ;
15
19
}
16
20
17
- private static void BenchmarkIsotopicEvelopeGeneration ( )
21
+ private static void BenchmarkIsotopicEnvelopeGeneration ( )
18
22
{
19
23
// Generate the formulas
20
24
var random = new Random ( 1 ) ;
21
25
22
- var chemicalFormulas = new IChemicalFormula [ MaxRunValue ] ;
26
+ var chemicalFormulas = new ChemicalFormula [ MaxRunValue ] ;
23
27
IElementProvider elementProvider = new MockElementProvider ( ) ;
24
28
25
29
for ( int i = 2 ; i < MaxRunValue ; i ++ )
@@ -62,5 +66,30 @@ private static void BenchmarkIsotopicEvelopeGeneration()
62
66
63
67
Console . WriteLine ( "Elapsed time for Northwestern Port: " + stopwatch . Elapsed ) ;
64
68
}
69
+
70
+ private static void BenchmarkChemicalFormulaAsKey ( )
71
+ {
72
+ IElementProvider elementProvider = new MockElementProvider ( ) ;
73
+ IResidueProvider residueProvider = new IupacAminoAcidProvider ( elementProvider ) ;
74
+
75
+ string sequence = "MLTELEKALNSIIDVYHKYSLIKGNFHAVYRDDLKKLLETECPQYIRKKGADVWFKELDINTDGAVNFQEFLILVIKMGVAAHKKSHEESHKE" ;
76
+ var residues = sequence . Select ( x => residueProvider . GetResidue ( x ) ) ;
77
+ ChemicalFormula [ ] formulas = residues . Select ( x => x . GetChemicalFormula ( ) ) . ToArray ( ) ;
78
+
79
+ Dictionary < ChemicalFormula , bool > dictionary = new ( ) ;
80
+ Stopwatch stopwatch = Stopwatch . StartNew ( ) ;
81
+
82
+ for ( int i = 0 ; i < 9_000 ; i ++ )
83
+ {
84
+ for ( int j = 0 ; j < formulas . Length ; j ++ )
85
+ {
86
+ if ( ! dictionary . ContainsKey ( formulas [ j ] ) )
87
+ dictionary . Add ( formulas [ j ] , true ) ;
88
+ }
89
+ }
90
+
91
+ stopwatch . Stop ( ) ;
92
+ Console . WriteLine ( stopwatch . Elapsed ) ;
93
+ }
65
94
}
66
95
}
0 commit comments