RDKit: DebugTrace.h Source File

| RDKit Open-source cheminformatics and machine learning.

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

DebugTrace.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2014 Novartis Institutes for BioMedical Research
3 //
4 // @@ All Rights Reserved @@
5 // This file is part of the RDKit.
6 // The contents are covered by the terms of the BSD license
7 // which is included in the file license.txt, found at the root
8 // of the RDKit source tree.
9 //
10 #pragma once
11 #include <stdio.h>
12 #include <string.h>
13 #include <stddef.h>
14 #include <time.h>
15 #include <iostream>
16 #ifdef _MSC_VER
17 #define _CRT_SECURE_NO_WARNINGS
18 #include <Windows.h> // for Winmm.lib timeGetTime()
19 #ifdef _DEBUG // check memory leaks
20 #include <crtdbg.h>
21 #define _CRTDBG_MAP_ALLOC
22 #ifndef new
23 #define new new (_NORMAL_BLOCK, __FILE__, __LINE__)
24 #endif
25 #endif
26 #else
27 #include <unistd.h>
28 #include <fcntl.h>
29 #include <sys/time.h>
30 #ifndef _WIN32
31 #include <sys/resource.h>
32 #endif
33 #endif
34
35 // SELECT ALGORITHM OPTIONS by comment some lines to exclude additional or
36 // experimental optimisations:
37
38 #define SEED_GROW_DEEP // fast and works much times faster (but it can depend
39 // on molecules)
40 //#define EXCLUDE_WRONG_COMPOSITION // fast but with a little effect, because
41 // amount of external bonds usually is very small.
42 // Exclude mismatched bonds combinations during seed growing (2^N-1 stage)
43
44 #define FAST_SUBSTRUCT_CACHE // based on a hash of Morgan code
45 #define DUP_SUBSTRUCT_CACHE // based on list of query atoms and bonds. For
46 // rings where seeds growing in both directions
47 // throw the same ring.
48
49 #define FAST_INCREMENTAL_MATCH // fast and some time very usefull. request
50 // PRECOMPUTED_TABLES_MATCH
51 // previous match result based match checking without finding new matched
52 // substructure location in the target
53
54 #define VERBOSE_STATISTICS_ON
55
56 #ifdef _MSC_VER
57 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
58
59 struct timezone {
60 int tz_minuteswest; // minutes W of Greenwich
61 int tz_dsttime; // type of dst correction
62 };
63
64 static inline int gettimeofday(struct timeval *tv, struct timezone *tz) {
65 FILETIME ft;
66 unsigned __int64 tmpres = 0;
67 static int tzflag;
68
69 if (NULL != tv) {
70 GetSystemTimeAsFileTime(&ft);
71
72 tmpres |= ft.dwHighDateTime;
73 tmpres <<= 32;
74 tmpres |= ft.dwLowDateTime;
75
76 // converting file time to unix epoch
77 tmpres -= DELTA_EPOCH_IN_MICROSECS;
78 tmpres /= 10; // convert into microseconds
79 tv->tv_sec = (long)(tmpres / 1000000UL);
80 tv->tv_usec = (long)(tmpres % 1000000UL);
81 }
82
83 if (NULL != tz) {
84 if (!tzflag) {
85 _tzset();
86 tzflag++;
87 }
88 tz->tz_minuteswest = _timezone / 60;
89 tz->tz_dsttime = _daylight;
90 }
91 return 0;
92 }
93 #endif
94
95 static inline unsigned long long nanoClock(
96 void) { // actually returns microseconds
97 struct timeval t;
98 gettimeofday(&t, (struct timezone *)0);
99 return t.tv_usec + t.tv_sec * 1000000ULL;
100 }
101
102 namespace RDKit {
103 namespace FMCS {
104
105 #ifdef VERBOSE_STATISTICS_ON
106
107 // compute statistics of really very very fast calls.
108 // It a bit decrease overal performance, but might be interested for
109 // investigation purpose (only)
110 //#define VERBOSE_STATISTICS_FASTCALLS_ON
111
112 struct ExecStatistics {
113 unsigned TotalSteps, MCSFoundStep;
114 unsigned long long MCSFoundTime;
115 unsigned InitialSeed, MismatchedInitialSeed;
116 unsigned Seed, RemainingSizeRejected;
117 unsigned SeedCheck, SingleBondExcluded;
118 unsigned MatchCall, MatchCallTrue;
119 unsigned FastMatchCall, FastMatchCallTrue, SlowMatchCallTrue;
120 unsigned ExactMatchCall, ExactMatchCallTrue; // hash cache
121 unsigned FindHashInCache, HashKeyFoundInCache;
122 unsigned AtomCompareCalls, BondCompareCalls; // long long
123 unsigned AtomFunctorCalls, BondFunctorCalls; // long long
124 unsigned WrongCompositionRejected, WrongCompositionDetected;
125 unsigned DupCacheFound, DupCacheFoundMatch;
126
127 ExecStatistics()
128 : TotalSteps(0),
129 MCSFoundStep(0),
130 MCSFoundTime(nanoClock()),
131 InitialSeed(0),
132 MismatchedInitialSeed(0),
133 Seed(0),
134 RemainingSizeRejected(0),
135 SeedCheck(0),
136 SingleBondExcluded(0),
137 MatchCall(0),
138 MatchCallTrue(0),
139 FastMatchCall(0),
140 FastMatchCallTrue(0),
141 SlowMatchCallTrue(0),
142 ExactMatchCall(0),
143 ExactMatchCallTrue(0),
144 FindHashInCache(0),
145 HashKeyFoundInCache(0),
146 AtomCompareCalls(0),
147 BondCompareCalls(0),
148 AtomFunctorCalls(0),
149 BondFunctorCalls(0),
150 WrongCompositionRejected(0),
151 WrongCompositionDetected(0),
152 DupCacheFound(0),
153 DupCacheFoundMatch(0) {}
154 };
155 #endif
156 }
157 }
RDKit::FMCS::ExecStatistics::TotalSteps
unsigned TotalSteps
Definition: DebugTrace.h:113
RDKit::FMCS::ExecStatistics::SlowMatchCallTrue
unsigned SlowMatchCallTrue
Definition: DebugTrace.h:119
RDKit::FMCS::ExecStatistics::BondCompareCalls
unsigned BondCompareCalls
Definition: DebugTrace.h:122
RDKit::FMCS::ExecStatistics::ExactMatchCallTrue
unsigned ExactMatchCallTrue
Definition: DebugTrace.h:120
RDKit::FMCS::ExecStatistics::HashKeyFoundInCache
unsigned HashKeyFoundInCache
Definition: DebugTrace.h:121
RDKit::FMCS::ExecStatistics::BondFunctorCalls
unsigned BondFunctorCalls
Definition: DebugTrace.h:123
RDKit::FMCS::ExecStatistics::SingleBondExcluded
unsigned SingleBondExcluded
Definition: DebugTrace.h:117
RDKit::FMCS::ExecStatistics
Definition: DebugTrace.h:112
nanoClock
static unsigned long long nanoClock(void)
Definition: DebugTrace.h:95
RDKit
Std stuff.
Definition: Atom.h:29
RDKit::FMCS::ExecStatistics::MatchCallTrue
unsigned MatchCallTrue
Definition: DebugTrace.h:118
RDKit::FMCS::ExecStatistics::MCSFoundTime
unsigned long long MCSFoundTime
Definition: DebugTrace.h:114
RDKit::FMCS::ExecStatistics::DupCacheFoundMatch
unsigned DupCacheFoundMatch
Definition: DebugTrace.h:125
RDKit::FMCS::ExecStatistics::Seed
unsigned Seed
Definition: DebugTrace.h:116
RDKit::FMCS::ExecStatistics::MismatchedInitialSeed
unsigned MismatchedInitialSeed
Definition: DebugTrace.h:115
RDKit::FMCS::ExecStatistics::WrongCompositionRejected
unsigned WrongCompositionRejected
Definition: DebugTrace.h:124
RDKit::FMCS::ExecStatistics::ExecStatistics
ExecStatistics()
Definition: DebugTrace.h:127