(
self,
niter,
dtype,
onlyidxquery,
onlynonidxquery,
avoidfscache,
verbose,
inkernel,
)
| 145 | self.print_mtime(t1, "Index time (%s)" % colname) |
| 146 | |
| 147 | def query_db( |
| 148 | self, |
| 149 | niter, |
| 150 | dtype, |
| 151 | onlyidxquery, |
| 152 | onlynonidxquery, |
| 153 | avoidfscache, |
| 154 | verbose, |
| 155 | inkernel, |
| 156 | ): |
| 157 | self.con = self.open_db() |
| 158 | if dtype == "int": |
| 159 | reg_cols = ["col1"] |
| 160 | idx_cols = ["col2"] |
| 161 | elif dtype == "float": |
| 162 | reg_cols = ["col3"] |
| 163 | idx_cols = ["col4"] |
| 164 | else: |
| 165 | reg_cols = ["col1", "col3"] |
| 166 | idx_cols = ["col2", "col4"] |
| 167 | if avoidfscache: |
| 168 | rseed = int(np.random.randint(self.nrows)) |
| 169 | else: |
| 170 | rseed = 19 |
| 171 | # Query for non-indexed columns |
| 172 | np.random.seed(rseed) |
| 173 | base = np.random.randint(self.nrows) |
| 174 | if not onlyidxquery: |
| 175 | for colname in reg_cols: |
| 176 | ltimes = [] |
| 177 | random.seed(rseed) |
| 178 | for i in range(NI_NTIMES): |
| 179 | t1 = clock() |
| 180 | results = self.do_query(self.con, colname, base, inkernel) |
| 181 | ltimes.append(clock() - t1) |
| 182 | if verbose: |
| 183 | print("Results len:", results) |
| 184 | self.print_qtime(colname, ltimes) |
| 185 | # Always reopen the file after *every* query loop. |
| 186 | # Necessary to make the benchmark to run correctly. |
| 187 | self.close_db(self.con) |
| 188 | self.con = self.open_db() |
| 189 | # Query for indexed columns |
| 190 | if not onlynonidxquery: |
| 191 | for colname in idx_cols: |
| 192 | ltimes = [] |
| 193 | np.random.seed(rseed) |
| 194 | rndbase = np.random.randint(self.nrows, size=niter) |
| 195 | # First, non-repeated queries |
| 196 | for i in range(niter): |
| 197 | base = rndbase[i] |
| 198 | t1 = clock() |
| 199 | results = self.do_query(self.con, colname, base, inkernel) |
| 200 | # results, tprof = self.do_query( |
| 201 | # self.con, colname, base, inkernel) |
| 202 | ltimes.append(clock() - t1) |
| 203 | if verbose: |
| 204 | print("Results len:", results) |
no test coverage detected