def bench_once(self, context, num_queries, invalidate_before=False): for _ in range(self.n): if invalidate_before: invalidate(db_alias=self.db_alias) with AssertNumQueries(num_queries, using=self.db_alias): start = time() self.query_function(self.db_alias) end = time() self.data.append( {'query': self.query_name, 'time': end - start, 'context': context, 'db': self.db_vendor, 'cache': self.cache_name})
def bench_once(self, context, num_queries, invalidate_before=False): for _ in range(self.n): if invalidate_before: invalidate(db_alias=self.db_alias) with AssertNumQueries(num_queries, using=self.db_alias): start = time() self.query_function(self.db_alias) end = time() self.data.append( {'query': self.query_name, 'time': end - start, 'context': context, 'db': self.db_vendor, 'cache': self.cache_name})
def bench_once(self, context, num_queries, invalidate_before=False): for _ in range(self.n): if invalidate_before: invalidate(db_alias=self.db_alias) with AssertNumQueries(num_queries, using=self.db_alias): start = time() self.query_function(self.db_alias) end = time() self.data.append( { "query": self.query_name, "time": end - start, "context": context, "db": self.db_vendor, "cache": self.cache_name, } )
def invalidate_cache(self): invalidate(self.db_table)