RDKit
Open-source cheminformatics and machine learning.
Loading...
Searching...
No Matches
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#include <RDGeneral/export.h>
11#pragma once
12#include <cstdio>
13#include <cstring>
14#include <cstddef>
15#include <ctime>
16#include <iostream>
17#ifdef _MSC_VER
18#define _CRT_SECURE_NO_WARNINGS
19#define NOMINMAX
20#include <Winsock2.h> // for timeval
21#ifdef _DEBUG // check memory leaks
22#include <crtdbg.h>
23#define _CRTDBG_MAP_ALLOC
24#ifndef new
25#define new new (_NORMAL_BLOCK, __FILE__, __LINE__)
26#endif
27#endif
28#else
29#include <unistd.h>
30#include <fcntl.h>
31#include <sys/time.h>
32#ifndef _WIN32
33#include <sys/resource.h>
34#endif
35#endif
36
37// SELECT ALGORITHM OPTIONS by comment some lines to exclude additional or
38// experimental optimisations:
39
40#define SEED_GROW_DEEP // fast and works much times faster (but it can depend
41 // on molecules)
42// #define EXCLUDE_WRONG_COMPOSITION // fast but with a little effect, because
43// amount of external bonds usually is very small.
44// Exclude mismatched bonds combinations during seed growing (2^N-1 stage)
45
46#define FAST_SUBSTRUCT_CACHE // based on a hash of Morgan code
47#define DUP_SUBSTRUCT_CACHE // based on list of query atoms and bonds. For
48 // rings where seeds growing in both directions
49 // throw the same ring.
50
51#define FAST_INCREMENTAL_MATCH // fast and some time very useful. request
52 // PRECOMPUTED_TABLES_MATCH
53// previous match result based match checking without finding new matched
54// substructure location in the target
55
56#define VERBOSE_STATISTICS_ON
57
58#ifdef _MSC_VER
59#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
60
61struct timezone {
62 int tz_minuteswest; // minutes W of Greenwich
63 int tz_dsttime; // type of dst correction
64};
65
66static inline int gettimeofday(struct timeval *tv, struct timezone *tz) {
67 FILETIME ft;
68 unsigned __int64 tmpres = 0;
69 static int tzflag;
70
71 if (nullptr != tv) {
72 GetSystemTimeAsFileTime(&ft);
73
74 tmpres |= ft.dwHighDateTime;
75 tmpres <<= 32;
76 tmpres |= ft.dwLowDateTime;
77
78 // converting file time to unix epoch
79 tmpres -= DELTA_EPOCH_IN_MICROSECS;
80 tmpres /= 10; // convert into microseconds
81 tv->tv_sec = (long)(tmpres / 1000000UL);
82 tv->tv_usec = (long)(tmpres % 1000000UL);
83 }
84
85 if (nullptr != tz) {
86 if (!tzflag) {
87 _tzset();
88 tzflag++;
89 }
90 tz->tz_minuteswest = _timezone / 60;
91 tz->tz_dsttime = _daylight;
92 }
93 return 0;
94}
95#endif
96
97static inline unsigned long long nanoClock(
98 void) { // actually returns microseconds
99 struct timeval t;
100 gettimeofday(&t, (struct timezone *)nullptr);
101 return t.tv_usec + t.tv_sec * 1000000ULL;
102}
103
104namespace RDKit {
105namespace FMCS {
106
107#ifdef VERBOSE_STATISTICS_ON
108
109// compute statistics of really very very fast calls.
110// It a bit decrease overal performance, but might be interested for
111// investigation purpose (only)
112// #define VERBOSE_STATISTICS_FASTCALLS_ON
113
115 unsigned int TotalSteps{0}, MCSFoundStep{0};
116 unsigned long long MCSFoundTime;
118 unsigned int Seed{0}, RemainingSizeRejected{0};
120 unsigned int MatchCall{0}, MatchCallTrue{0};
122 unsigned int ExactMatchCall{0}, ExactMatchCallTrue{0}; // hash cache
128
130};
131#endif
132} // namespace FMCS
133} // namespace RDKit
static unsigned long long nanoClock(void)
Definition DebugTrace.h:97
Std stuff.
unsigned long long MCSFoundTime
Definition DebugTrace.h:116
unsigned int RemainingSizeRejected
Definition DebugTrace.h:118
unsigned int WrongCompositionDetected
Definition DebugTrace.h:126
unsigned int DupCacheFoundMatch
Definition DebugTrace.h:127
unsigned int MismatchedInitialSeed
Definition DebugTrace.h:117
unsigned int ExactMatchCallTrue
Definition DebugTrace.h:122
unsigned int IndividualBondExcluded
Definition DebugTrace.h:119
unsigned int WrongCompositionRejected
Definition DebugTrace.h:126
unsigned int HashKeyFoundInCache
Definition DebugTrace.h:123