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 WIN32
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 #include <sys/resource.h>
31 #endif
32
33 // SELECT ALGORITHM OPTIONS by comment some lines to exclude additional or
34 // experimental optimisations:
35
36 #define SEED_GROW_DEEP // fast and works much times faster (but it can depend
37 // on molecules)
38 //#define EXCLUDE_WRONG_COMPOSITION // fast but with a little effect, because
39 // amount of external bonds usually is very small.
40 // Exclude mismatched bonds combinations during seed growing (2^N-1 stage)
41
42 #define FAST_SUBSTRUCT_CACHE // based on a hash of Morgan code
43 #define DUP_SUBSTRUCT_CACHE // based on list of query atoms and bonds. For
44 // rings where seeds growing in both directions
45 // throw the same ring.
46
47 #define FAST_INCREMENTAL_MATCH // fast and some time very usefull. request
48 // PRECOMPUTED_TABLES_MATCH
49 // previous match result based match checking without finding new matched
50 // substructure location in the target
51
52 #define VERBOSE_STATISTICS_ON
53
54 #ifdef WIN32
55 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
56
57 struct timezone {
58 int tz_minuteswest; // minutes W of Greenwich
59 int tz_dsttime; // type of dst correction
60 };
61
62 static inline int gettimeofday(struct timeval *tv, struct timezone *tz) {
63 FILETIME ft;
64 unsigned __int64 tmpres = 0;
65 static int tzflag;
66
67 if (NULL != tv) {
68 GetSystemTimeAsFileTime(&ft);
69
70 tmpres |= ft.dwHighDateTime;
71 tmpres <<= 32;
72 tmpres |= ft.dwLowDateTime;
73
74 // converting file time to unix epoch
75 tmpres -= DELTA_EPOCH_IN_MICROSECS;
76 tmpres /= 10; // convert into microseconds
77 tv->tv_sec = (long)(tmpres / 1000000UL);
78 tv->tv_usec = (long)(tmpres % 1000000UL);
79 }
80
81 if (NULL != tz) {
82 if (!tzflag) {
83 _tzset();
84 tzflag++;
85 }
86 tz->tz_minuteswest = _timezone / 60;
87 tz->tz_dsttime = _daylight;
88 }
89 return 0;
90 }
91 #endif
92
93 static inline unsigned long long nanoClock(
94 void) { // actually returns microseconds
95 struct timeval t;
96 gettimeofday(&t, (struct timezone *)0);
97 return t.tv_usec + t.tv_sec * 1000000ULL;
98 }
99
100 namespace RDKit {
101 namespace FMCS {
102
103 #ifdef VERBOSE_STATISTICS_ON
104
105 // compute statistics of really very very fast calls.
106 // It a bit decrease overal performance, but might be interested for
107 // investigation purpose (only)
108 //#define VERBOSE_STATISTICS_FASTCALLS_ON
109
110 struct ExecStatistics {
111 unsigned TotalSteps, MCSFoundStep;
112 unsigned long long MCSFoundTime;
113 unsigned InitialSeed, MismatchedInitialSeed;
114 unsigned Seed, RemainingSizeRejected;
115 unsigned SeedCheck, SingleBondExcluded;
116 unsigned MatchCall, MatchCallTrue;
117 unsigned FastMatchCall, FastMatchCallTrue, SlowMatchCallTrue;
118 unsigned ExactMatchCall, ExactMatchCallTrue; // hash cache
119 unsigned FindHashInCache, HashKeyFoundInCache;
120 unsigned AtomCompareCalls, BondCompareCalls; // long long
121 unsigned AtomFunctorCalls, BondFunctorCalls; // long long
122 unsigned WrongCompositionRejected, WrongCompositionDetected;
123 unsigned DupCacheFound, DupCacheFoundMatch;
124
125 ExecStatistics()
126 : TotalSteps(0),
127 MCSFoundStep(0),
128 MCSFoundTime(nanoClock()),
129 InitialSeed(0),
130 MismatchedInitialSeed(0),
131 Seed(0),
132 RemainingSizeRejected(0),
133 SeedCheck(0),
134 SingleBondExcluded(0),
135 MatchCall(0),
136 MatchCallTrue(0),
137 FastMatchCall(0),
138 FastMatchCallTrue(0),
139 SlowMatchCallTrue(0),
140 ExactMatchCall(0),
141 ExactMatchCallTrue(0),
142 FindHashInCache(0),
143 HashKeyFoundInCache(0),
144 AtomCompareCalls(0),
145 BondCompareCalls(0),
146 AtomFunctorCalls(0),
147 BondFunctorCalls(0),
148 WrongCompositionRejected(0),
149 WrongCompositionDetected(0),
150 DupCacheFound(0),
151 DupCacheFoundMatch(0) {}
152 };
153 #endif
154 }
155 }
RDKit::FMCS::ExecStatistics::TotalSteps
unsigned TotalSteps
Definition: DebugTrace.h:111
RDKit::FMCS::ExecStatistics::SlowMatchCallTrue
unsigned SlowMatchCallTrue
Definition: DebugTrace.h:117
RDKit::FMCS::ExecStatistics::BondCompareCalls
unsigned BondCompareCalls
Definition: DebugTrace.h:120
RDKit::FMCS::ExecStatistics::AtomFunctorCalls
unsigned AtomFunctorCalls
Definition: DebugTrace.h:121
RDKit::FMCS::ExecStatistics::ExactMatchCallTrue
unsigned ExactMatchCallTrue
Definition: DebugTrace.h:118
RDKit::FMCS::ExecStatistics::HashKeyFoundInCache
unsigned HashKeyFoundInCache
Definition: DebugTrace.h:119
RDKit::FMCS::ExecStatistics::BondFunctorCalls
unsigned BondFunctorCalls
Definition: DebugTrace.h:121
RDKit::FMCS::ExecStatistics::DupCacheFound
unsigned DupCacheFound
Definition: DebugTrace.h:123
RDKit::FMCS::ExecStatistics::SeedCheck
unsigned SeedCheck
Definition: DebugTrace.h:115
RDKit::FMCS::ExecStatistics::AtomCompareCalls
unsigned AtomCompareCalls
Definition: DebugTrace.h:120
RDKit::FMCS::ExecStatistics::MatchCall
unsigned MatchCall
Definition: DebugTrace.h:116
RDKit::FMCS::ExecStatistics::SingleBondExcluded
unsigned SingleBondExcluded
Definition: DebugTrace.h:115
RDKit::FMCS::ExecStatistics::FastMatchCallTrue
unsigned FastMatchCallTrue
Definition: DebugTrace.h:117
RDKit::FMCS::ExecStatistics::FindHashInCache
unsigned FindHashInCache
Definition: DebugTrace.h:119
RDKit::FMCS::ExecStatistics
Definition: DebugTrace.h:110
RDKit::FMCS::ExecStatistics::WrongCompositionDetected
unsigned WrongCompositionDetected
Definition: DebugTrace.h:122
RDKit::FMCS::ExecStatistics::RemainingSizeRejected
unsigned RemainingSizeRejected
Definition: DebugTrace.h:114
nanoClock
static unsigned long long nanoClock(void)
Definition: DebugTrace.h:93
RDKit
Includes a bunch of functionality for handling Atom and Bond queries.
Definition: Atom.h:28
RDKit::FMCS::ExecStatistics::InitialSeed
unsigned InitialSeed
Definition: DebugTrace.h:113
RDKit::FMCS::ExecStatistics::MatchCallTrue
unsigned MatchCallTrue
Definition: DebugTrace.h:116
RDKit::FMCS::ExecStatistics::MCSFoundTime
unsigned long long MCSFoundTime
Definition: DebugTrace.h:112
RDKit::FMCS::ExecStatistics::ExactMatchCall
unsigned ExactMatchCall
Definition: DebugTrace.h:118
RDKit::FMCS::ExecStatistics::DupCacheFoundMatch
unsigned DupCacheFoundMatch
Definition: DebugTrace.h:123
RDKit::FMCS::ExecStatistics::Seed
unsigned Seed
Definition: DebugTrace.h:114
RDKit::FMCS::ExecStatistics::FastMatchCall
unsigned FastMatchCall
Definition: DebugTrace.h:117
RDKit::FMCS::ExecStatistics::MismatchedInitialSeed
unsigned MismatchedInitialSeed
Definition: DebugTrace.h:113
RDKit::FMCS::ExecStatistics::MCSFoundStep
unsigned MCSFoundStep
Definition: DebugTrace.h:111
RDKit::FMCS::ExecStatistics::WrongCompositionRejected
unsigned WrongCompositionRejected
Definition: DebugTrace.h:122
RDKit::FMCS::ExecStatistics::ExecStatistics
ExecStatistics()
Definition: DebugTrace.h:125