File: DebugTrace.h

package info (click to toggle)
rdkit 201809.1%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 123,688 kB
  • sloc: cpp: 230,509; python: 70,501; java: 6,329; ansic: 5,427; sql: 1,899; yacc: 1,739; lex: 1,243; makefile: 445; xml: 229; fortran: 183; sh: 123; cs: 93
file content (158 lines) | stat: -rw-r--r-- 4,606 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
//
//  Copyright (C) 2014 Novartis Institutes for BioMedical Research
//
//   @@ All Rights Reserved @@
//  This file is part of the RDKit.
//  The contents are covered by the terms of the BSD license
//  which is included in the file license.txt, found at the root
//  of the RDKit source tree.
//
#include <RDGeneral/export.h>
#pragma once
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <time.h>
#include <iostream>
#ifdef _MSC_VER
#define _CRT_SECURE_NO_WARNINGS
#include <Windows.h>  // for Winmm.lib timeGetTime()
#ifdef _DEBUG         // check memory leaks
#include <crtdbg.h>
#define _CRTDBG_MAP_ALLOC
#ifndef new
#define new new (_NORMAL_BLOCK, __FILE__, __LINE__)
#endif
#endif
#else
#include <unistd.h>
#include <fcntl.h>
#include <sys/time.h>
#ifndef _WIN32
#include <sys/resource.h>
#endif
#endif

// SELECT ALGORITHM OPTIONS by comment some lines to exclude additional or
// experimental optimisations:

#define SEED_GROW_DEEP  // fast and works much times faster (but it can depend
                        // on molecules)
//#define EXCLUDE_WRONG_COMPOSITION   // fast but with a little effect, because
// amount of external bonds usually is very small.
// Exclude mismatched bonds combinations during seed growing (2^N-1 stage)

#define FAST_SUBSTRUCT_CACHE  // based on a hash of Morgan code
#define DUP_SUBSTRUCT_CACHE   // based on list of query atoms and bonds. For
                              // rings where seeds growing in both directions
                              // throw the same ring.

#define FAST_INCREMENTAL_MATCH  // fast and some time very usefull. request
                                // PRECOMPUTED_TABLES_MATCH
// previous match result based match checking without finding new matched
// substructure location in the target

#define VERBOSE_STATISTICS_ON

#ifdef _MSC_VER
#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL

struct timezone {
  int tz_minuteswest;  // minutes W of Greenwich
  int tz_dsttime;      // type of dst correction
};

static inline int gettimeofday(struct timeval *tv, struct timezone *tz) {
  FILETIME ft;
  unsigned __int64 tmpres = 0;
  static int tzflag;

  if (NULL != tv) {
    GetSystemTimeAsFileTime(&ft);

    tmpres |= ft.dwHighDateTime;
    tmpres <<= 32;
    tmpres |= ft.dwLowDateTime;

    // converting file time to unix epoch
    tmpres -= DELTA_EPOCH_IN_MICROSECS;
    tmpres /= 10;  // convert into microseconds
    tv->tv_sec = (long)(tmpres / 1000000UL);
    tv->tv_usec = (long)(tmpres % 1000000UL);
  }

  if (NULL != tz) {
    if (!tzflag) {
      _tzset();
      tzflag++;
    }
    tz->tz_minuteswest = _timezone / 60;
    tz->tz_dsttime = _daylight;
  }
  return 0;
}
#endif

static inline unsigned long long nanoClock(
    void) {  // actually returns microseconds
  struct timeval t;
  gettimeofday(&t, (struct timezone *)0);
  return t.tv_usec + t.tv_sec * 1000000ULL;
}

namespace RDKit {
namespace FMCS {

#ifdef VERBOSE_STATISTICS_ON

// compute statistics of really very very fast calls.
// It a bit decrease overal performance, but might be interested for
// investigation purpose (only)
//#define VERBOSE_STATISTICS_FASTCALLS_ON

struct ExecStatistics {
  unsigned TotalSteps, MCSFoundStep;
  unsigned long long MCSFoundTime;
  unsigned InitialSeed, MismatchedInitialSeed;
  unsigned Seed, RemainingSizeRejected;
  unsigned SeedCheck, SingleBondExcluded;
  unsigned MatchCall, MatchCallTrue;
  unsigned FastMatchCall, FastMatchCallTrue, SlowMatchCallTrue;
  unsigned ExactMatchCall, ExactMatchCallTrue;  // hash cache
  unsigned FindHashInCache, HashKeyFoundInCache;
  unsigned AtomCompareCalls, BondCompareCalls;  // long long
  unsigned AtomFunctorCalls, BondFunctorCalls;  // long long
  unsigned WrongCompositionRejected, WrongCompositionDetected;
  unsigned DupCacheFound, DupCacheFoundMatch;

  ExecStatistics()
      : TotalSteps(0),
        MCSFoundStep(0),
        MCSFoundTime(nanoClock()),
        InitialSeed(0),
        MismatchedInitialSeed(0),
        Seed(0),
        RemainingSizeRejected(0),
        SeedCheck(0),
        SingleBondExcluded(0),
        MatchCall(0),
        MatchCallTrue(0),
        FastMatchCall(0),
        FastMatchCallTrue(0),
        SlowMatchCallTrue(0),
        ExactMatchCall(0),
        ExactMatchCallTrue(0),
        FindHashInCache(0),
        HashKeyFoundInCache(0),
        AtomCompareCalls(0),
        BondCompareCalls(0),
        AtomFunctorCalls(0),
        BondFunctorCalls(0),
        WrongCompositionRejected(0),
        WrongCompositionDetected(0),
        DupCacheFound(0),
        DupCacheFoundMatch(0) {}
};
#endif
}
}