Skip to content

Commit

Permalink
Improve performance and disable clock timing
Browse files Browse the repository at this point in the history
Former-commit-id: 085b8cd561cfa66c78dfc7bd7147d67b96d95af8
  • Loading branch information
alchemistmatt committed Aug 2, 2013
1 parent 65ca656 commit 758b548
Show file tree
Hide file tree
Showing 10 changed files with 145 additions and 88 deletions.
42 changes: 26 additions & 16 deletions ChargeDetermination/AutoCorrelationChargeDetermination.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,26 +35,27 @@ namespace Engine

void AutoCorrelationChargeDetermine::ACss(std::vector<double> &Iv, std::vector<double> &Ov)
{
int i,j;
float sum,ave;
int i,j,topIndex;
double sum,ave;

int IvN = (int)Iv.size() ;

ave=0.0;
for(j=0;j<IvN;j++)
ave += (float) Iv[j];
ave += Iv[j];
ave = ave/IvN;
// for(i=0;i<IvN/2;i++) GAA 09/27/03
for(i=0;i<IvN;i++)
{
sum = 0.0;
for(j=0;j<IvN-i-1;j++)
sum += (float)((Iv[j]-ave) * (Iv[j+i]-ave));
topIndex = IvN-i-1;
for(j=0;j<topIndex;j++)
sum += ((Iv[j]-ave) * (Iv[j+i]-ave));

if(j > 0)
{
// too much weight given to high charges this way. DJ Jan 07 2007
Ov.push_back(sum/IvN) ;
Ov.push_back((float)(sum/IvN)) ;
//Ov.push_back(sum/j) ;
}
else
Expand All @@ -64,7 +65,8 @@ namespace Engine

short AutoCorrelationChargeDetermine::GetChargeState(PeakProcessing::Peak &pk, PeakProcessing::PeakData &peak_data, bool debug)
{
clock_t auto_start_t = clock() ;
// Disable timing (MEM 2013)
// clock_t auto_start_t = clock() ;
debug = false ;

double minMZ, maxMZ ;
Expand Down Expand Up @@ -102,7 +104,8 @@ namespace Engine
mvect_Y.push_back(intensity) ;
}

clock_t start_t = clock() ;
// Disable timing (MEM 2013)
// clock_t start_t = clock() ;
mobj_interpolation.Spline(mvect_X, mvect_Y, 0, 0) ;

minMZ = mvect_X[0];
Expand All @@ -118,8 +121,9 @@ namespace Engine
fVal = mobj_interpolation.Splint(mvect_X, mvect_Y, xVal);
mvect_Iv.push_back(fVal) ;
}
clock_t stop_t = clock() ;
mint_spline_time += (stop_t - start_t) ;
// Disable timing (MEM 2013)
// clock_t stop_t = clock() ;
// mint_spline_time += (stop_t - start_t) ;

if (debug)
{
Expand All @@ -132,7 +136,9 @@ namespace Engine
}
}

start_t = clock() ;
// Disable timing (MEM 2013)
// start_t = clock() ;

ACss(mvect_Iv, mvect_autocorrelation_scores);
if (debug)
{
Expand All @@ -145,8 +151,9 @@ namespace Engine
}
}

stop_t = clock() ;
mint_autocorrelation_time += (stop_t - start_t) ;
// Disable timing (MEM 2013)
// stop_t = clock() ;
// mint_autocorrelation_time += (stop_t - start_t) ;

int j=0;
int minN ;
Expand Down Expand Up @@ -209,7 +216,8 @@ namespace Engine
found = peak_data.GetPeakFromAllOriginalIntensity(peakA - FWHM, peakA + FWHM, iso_peak) ;
if (found)
{
mint_total_cs_time += (clock() - auto_start_t) ;
// Disable timing (MEM 2013)
// mint_total_cs_time += (clock() - auto_start_t) ;
return tmp ;
}
}
Expand All @@ -219,14 +227,16 @@ namespace Engine
found = peak_data.GetPeakFromAllOriginalIntensity(peakA - FWHM, peakA + FWHM, iso_peak) ;
if (found && iso_peak.mdbl_mz * tmp < 3000)
{
mint_total_cs_time += (clock() - auto_start_t) ;
// Disable timing (MEM 2013)
// mint_total_cs_time += (clock() - auto_start_t) ;
return tmp ;
}
}
}
}

mint_total_cs_time += (clock() - auto_start_t) ;
// Disable timing (MEM 2013)
// mint_total_cs_time += (clock() - auto_start_t) ;
return returnCSVal;
}

Expand Down
2 changes: 1 addition & 1 deletion DeconEngine.sdf.REMOVED.git-id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1cbead774513b91da7785109ff6d94f1a7c1bd3a
c4ea9077030eabdeb273d15369f98081f813e204
16 changes: 0 additions & 16 deletions DeconEngine.sln
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DeconEngineV2", "DeconEngin
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnitTests", "UnitTests\UnitTests\UnitTests.csproj", "{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleBasedTesting", "..\ConsoleBasedTesting\ConsoleBasedTesting.csproj", "{9E48169B-1AE5-442F-AC76-F0B543906886}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -35,29 +33,15 @@ Global
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Debug|Any CPU.ActiveCfg = Debug|x86
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Debug|Any CPU.Build.0 = Debug|x86
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Debug|Mixed Platforms.Build.0 = Debug|x86
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Debug|Win32.ActiveCfg = Debug|Any CPU
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Debug|x86.ActiveCfg = Debug|x86
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Debug|x86.Build.0 = Debug|x86
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Release|Any CPU.Build.0 = Release|Any CPU
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Release|Win32.ActiveCfg = Release|Any CPU
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Release|x86.ActiveCfg = Release|x86
{0B6C729C-17D9-4960-BDC4-2BEB56FED18E}.Release|x86.Build.0 = Release|x86
{9E48169B-1AE5-442F-AC76-F0B543906886}.Debug|Any CPU.ActiveCfg = Debug|x86
{9E48169B-1AE5-442F-AC76-F0B543906886}.Debug|Mixed Platforms.ActiveCfg = Debug|x86
{9E48169B-1AE5-442F-AC76-F0B543906886}.Debug|Mixed Platforms.Build.0 = Debug|x86
{9E48169B-1AE5-442F-AC76-F0B543906886}.Debug|Win32.ActiveCfg = Debug|x86
{9E48169B-1AE5-442F-AC76-F0B543906886}.Debug|x86.ActiveCfg = Debug|x86
{9E48169B-1AE5-442F-AC76-F0B543906886}.Debug|x86.Build.0 = Debug|x86
{9E48169B-1AE5-442F-AC76-F0B543906886}.Release|Any CPU.ActiveCfg = Release|x86
{9E48169B-1AE5-442F-AC76-F0B543906886}.Release|Mixed Platforms.ActiveCfg = Release|x86
{9E48169B-1AE5-442F-AC76-F0B543906886}.Release|Mixed Platforms.Build.0 = Release|x86
{9E48169B-1AE5-442F-AC76-F0B543906886}.Release|Win32.ActiveCfg = Release|x86
{9E48169B-1AE5-442F-AC76-F0B543906886}.Release|x86.ActiveCfg = Release|x86
{9E48169B-1AE5-442F-AC76-F0B543906886}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
6 changes: 3 additions & 3 deletions DeconEngine.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<Link>
<AdditionalDependencies>mscoree.lib;msvcrtd.lib;Ws2_32.lib;xerces-c_2.lib;msvcrt.lib;xerces-c_2D.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
<AdditionalLibraryDirectories>C:\xerces\xerces-c-windows_2000-msvc_60\lib;C:\xerces\xerces-c_2_8_0-x86-windows-vc_7_1\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>C:\xerces\xerces-c_2_8_0-x86-windows-vc_7_1\lib;C:\xerces\xerces-c-windows_2000-msvc_60\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ForceSymbolReferences>__DllMainCRTStartup%4012;%(ForceSymbolReferences)</ForceSymbolReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AssemblyDebug>true</AssemblyDebug>
Expand All @@ -79,7 +79,7 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<AdditionalIncludeDirectories>C:\xerces\xerces-c-windows_2000-msvc_60\include\;C:\PNL\LTE\Proteomics\xerces-c-windows_2000-msvc_60\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>C:\xerces\xerces-c_2_8_0-x86-windows-vc_7_1\include\;C:\xerces\xerces-c-windows_2000-msvc_60\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;MASSLYNX_4_INSTALLED;ANALYST_INSTALLED;XCALIBUR_INSTALLED;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>false</MinimalRebuild>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
Expand All @@ -93,7 +93,7 @@
<Link>
<AdditionalDependencies>mscoree.lib;msvcrt.lib;Ws2_32.lib;xerces-c_2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<OutputFile>$(OutDir)$(ProjectName).dll</OutputFile>
<AdditionalLibraryDirectories>C:\xerces\xerces-c-windows_2000-msvc_60\lib;C:\PNL\LTE\Proteomics\xerces-c-windows_2000-msvc_60\lib;C:\Projects\Decon2LS\DeconEngine\bin;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalLibraryDirectories>C:\xerces\xerces-c_2_8_0-x86-windows-vc_7_1\lib;C:\xerces\xerces-c-windows_2000-msvc_60\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<ForceSymbolReferences>__DllMainCRTStartup%4012;%(ForceSymbolReferences)</ForceSymbolReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
Expand Down
17 changes: 11 additions & 6 deletions HornTransform/AreaFit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ namespace Engine
bool debug)
{

clock_t start_t = clock() ;
// Disable timing (MEM 2013)
// clock_t start_t = clock() ;
int num_points = (int)mvect_distribution_mzs.size() ;
if (num_points < 3)
return 1 ;
Expand Down Expand Up @@ -63,8 +64,9 @@ namespace Engine
}
}

clock_t stop_t = clock() ;
mint_fit_processing_time += (stop_t - start_t) ;
// Disable timing (MEM 2013)
// clock_t stop_t = clock() ;
// mint_fit_processing_time += (stop_t - start_t) ;

return fit/(sum + 0.001) ;
}
Expand All @@ -73,7 +75,8 @@ namespace Engine
double intensity_normalizer, double mz_delta, double min_intensity_for_score,
bool debug )
{
clock_t start_t = clock() ;
// Disable timing (MEM 2013)
// clock_t start_t = clock() ;
int num_points = (int)mvect_distribution_mzs.size() ;
if (num_points < 3)
return 1 ;
Expand All @@ -95,8 +98,10 @@ namespace Engine
sum += theoretical_intensity * theoretical_intensity ;
}
}
clock_t stop_t = clock() ;
mint_fit_processing_time += (stop_t - start_t) ;

// Disable timing (MEM 2013)
// clock_t stop_t = clock() ;
// mint_fit_processing_time += (stop_t - start_t) ;

return fit/(sum + 0.001) ;
}
Expand Down
16 changes: 10 additions & 6 deletions HornTransform/ChiSqFit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ namespace Engine
double ChiSqFit::FitScore(PeakProcessing::PeakData &pk_data, short cs, PeakProcessing::Peak &pk, double mz_delta,
double min_intensity_for_score, bool debug)
{
clock_t start_t = clock() ;
// Disable timing (MEM 2013)
// clock_t start_t = clock() ;
int num_points = (int)mvect_distribution_mzs.size() ;
if (num_points < 3)
return 1 ;
Expand All @@ -50,15 +51,17 @@ namespace Engine
}
}

clock_t stop_t = clock() ;
mint_fit_processing_time += (stop_t - start_t) ;
// Disable timing (MEM 2013)
// clock_t stop_t = clock() ;
// mint_fit_processing_time += (stop_t - start_t) ;
return fit/(sum + 0.001) ;
}

double ChiSqFit::FitScore(PeakProcessing::PeakData &pk_data, short cs, double intensity_normalizer, double mz_delta,
double min_intensity_for_score, bool debug)
{
clock_t start_t = clock() ;
// Disable timing (MEM 2013)
// clock_t start_t = clock() ;

int num_points = (int)mvect_distribution_mzs.size() ;
if (num_points < 3)
Expand All @@ -82,8 +85,9 @@ namespace Engine
sum += theoretical_intensity * observed_intensity ;
}
}
clock_t stop_t = clock() ;
mint_fit_processing_time += (stop_t - start_t) ;
// Disable timing (MEM 2013)
// clock_t stop_t = clock() ;
// mint_fit_processing_time += (stop_t - start_t) ;

return fit/(sum + 0.001) ;
}
Expand Down
28 changes: 18 additions & 10 deletions HornTransform/IsotopeFit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ namespace Engine

bool IsotopeFit::FindPeak(double min_mz, double max_mz, double &mz_value, double &intensity, bool debug)
{
clock_t start_t = clock() ;
// Disable timing (MEM 2013)
// clock_t start_t = clock() ;
if (!mbln_last_value_was_cached)
{
bool found = mobj_isotope_dist.FindPeak(min_mz, max_mz, mz_value, intensity) ;
mint_find_peak_calc += (clock() - start_t) ;
// Disable timing (MEM 2013)
// mint_find_peak_calc += (clock() - start_t) ;
return found ;
}

Expand Down Expand Up @@ -106,7 +108,8 @@ namespace Engine
}
if (max_index == -1)
{
mint_find_peak_cached += (clock() - start_t) ;
// Disable timing (MEM 2013)
// mint_find_peak_cached += (clock() - start_t) ;
return false ;
}

Expand Down Expand Up @@ -141,13 +144,16 @@ namespace Engine
mz_value = X2 ;
intensity = mvect_distribution_intensities[max_index] ;
}
mint_find_peak_cached += (clock() - start_t) ;
// Disable timing (MEM 2013)
// mint_find_peak_cached += (clock() - start_t) ;
return true ;
}

mz_value = X2 ;
intensity = mvect_distribution_intensities[max_index] ;
mint_find_peak_cached += (clock() - start_t) ;

// Disable timing (MEM 2013)
// mint_find_peak_cached += (clock() - start_t) ;
return true ;
}

Expand Down Expand Up @@ -687,9 +693,9 @@ namespace Engine
{
double current_mz = most_abundant_mass/charge + mdbl_cc_mass ;
double FWHM = current_mz / resolution ;
clock_t start_t = clock() ;



// Disable timing (MEM 2013)
// clock_t start_t = clock() ;

//first check the UseCaching option; then check if it is in the cache or not.
//if it is in the cache, the data is retrieved and the method returns true
Expand Down Expand Up @@ -733,8 +739,10 @@ namespace Engine
mobj_isotope_dist.mdbl_most_intense_mw = mobj_mercury_cache.mdbl_most_intense_mw ;
mobj_isotope_dist.mdbl_max_peak_mz = mobj_mercury_cache.mdbl_most_intense_mw/charge + mdbl_cc_mass - ELECTRON_MASS ;
}
clock_t stop_t = clock() ;
mint_distribution_processing_time += (stop_t - start_t) ;

// Disable timing (MEM 2013)
// clock_t stop_t = clock() ;
// mint_distribution_processing_time += (stop_t - start_t) ;

return ;
}
Expand Down
15 changes: 10 additions & 5 deletions HornTransform/MassTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,9 @@ namespace Engine
}
}
double best_fit = 0 ;
clock_t start_t = clock() ;


// Disable timing (MEM 2013)
// clock_t start_t = clock() ;

PeakProcessing::Peak pkCharge1 = pk ;

Expand Down Expand Up @@ -255,7 +256,8 @@ namespace Engine
}
}

mint_get_fit_score_time += (clock() - start_t) ;
// Disable timing (MEM 2013)
// mint_get_fit_score_time += (clock() - start_t) ;

if (best_fit > mdbl_max_fit) // check if fit is good enough
return false ;
Expand All @@ -273,11 +275,14 @@ namespace Engine
PeakProcessing::Peak m3_peak ;
double mono_pls_two_mz = record.mdbl_mono_mw / record.mshort_cs + 2.0/record.mshort_cs + mdbl_cc_mass ;

start_t = clock() ;
// Disable timing (MEM 2013)
// start_t = clock() ;
pk_data.FindPeak(mono_mz - pk.mdbl_FWHM, mono_mz + pk.mdbl_FWHM, mono_peak) ;

pk_data.FindPeak(mono_pls_two_mz - pk.mdbl_FWHM, mono_pls_two_mz + pk.mdbl_FWHM, m3_peak) ;
mint_remaining_time += (clock() - start_t) ;

// Disable timing (MEM 2013)
// mint_remaining_time += (clock() - start_t) ;

record.mint_mono_intensity = (int) mono_peak.mdbl_intensity ;
record.mint_iplus2_intensity = (int) m3_peak.mdbl_intensity ;
Expand Down
Loading

0 comments on commit 758b548

Please sign in to comment.