Ejemplo n.º 1
0
 def execSql(self, sql):
     try:
         self._dbc.execute(sql)
     except taos.error.ProgrammingError as err:
         Logging.warning("SQL Error: 0x{:X}, {}, SQL: {}".format(
             Helper.convertErrno(err.errno), err.msg, sql))
         raise
Ejemplo n.º 2
0
    def run(self):
        print("Running benchmark: {}, class={} ...".format(
            self.name, self.__class__))
        startTime = time.time()

        # Prepare to execute the benchmark
        self.prepare()

        # Actually execute the benchmark
        self.execute()

        # if Config.getConfig().iterate_directly: # execute directly
        #     Logging.debug("Iterating...")
        #     self.doIterate()
        # else:
        #     Logging.debug("Executing via sub process...")
        #     startTime = time.time()
        #     self.prepare()
        #     self.spawnProcesses()
        #     self.waitForProcecess()
        #     duration = time.time() - startTime
        #     Logging.info("Benchmark execution completed in {:.3f} seconds".format(duration))
        Logging.info("Benchmark {} finished in {:.3f} seconds".format(
            self.name,
            time.time() - startTime))
Ejemplo n.º 3
0
 def _setLoopCount(self, loopCount):
     cfgLoopCount = Config.getConfig().loop_count
     if loopCount == 0:  # use config
         self._loopCount = cfgLoopCount
     else:
         if cfgLoopCount:
             Logging.warning(
                 "Ignoring loop count for fixed-loop-count benchmarks: {}".
                 format(cfgLoopCount))
         self._loopCount = loopCount
Ejemplo n.º 4
0
    def doIterate(self):
        tblName = Config.getConfig().target_table_name
        print("Benchmarking TAOS database (1 pass) for: {}".format(tblName))
        self._dbc.execute("USE {}".format(DB_NAME))

        self._sTable.ensureRegTable(None, self._dbc, tblName)
        try:
            lCount = Config.getConfig().loop_count
            print("({})".format(lCount))
            for i in range(0, lCount):
                writeTaosBatch(self._dbc, tblName)
        except taos.error.ProgrammingError as err:
            Logging.error("Failed to write batch")
Ejemplo n.º 5
0
def main():
    parser = _buildCmdLineParser()
    Config.init(parser)
    Logging.clsInit(Config.getConfig().debug)
    Dice.seed(0)  # initial seeding of dice

    bName = Config.getConfig().benchmark_name
    bClassName = bName + 'Benchmark'
    x = globals()
    if bClassName in globals():
        bClass = globals()[bClassName]
        bm = bClass()  # Benchmark object
        bm.run()
    else:
        raise PerfGenError("No such benchmark: {}".format(bName))
Ejemplo n.º 6
0
    def executeWrite(self):
        # Sample: INSERT INTO t1 USING st TAGS(1) VALUES(now, 1) t2 USING st TAGS(2) VALUES(now, 2)
        sqlPrefix = "INSERT INTO "
        dataTemplate = "{} USING {} TAGS({},{},'barcode_{}') VALUES('{}',{},{},'{}') "

        stName = self._sTable.getName()
        BATCH_SIZE = 2000  # number of items per request batch
        ITEMS_PER_SHELF = 5

        # rackSize = 10 # shelves per rack
        # shelfSize = 100  # items per shelf
        batchCount = self._loopCount // BATCH_SIZE
        lastRack = 0
        for i in range(batchCount):
            sql = sqlPrefix
            for j in range(BATCH_SIZE):
                n = i * BATCH_SIZE + j  # serial number
                # values first
                # rtName = 'rt_' + str(n) # table name contains serial number, has info
                temperature = 20 + (n % 10)
                pressure = 70 + (n % 10)
                # tags
                shelf = (n // ITEMS_PER_SHELF) % MAX_SHELF  # shelf number
                rack = n // (ITEMS_PER_SHELF * MAX_SHELF)  # rack number
                barcode = rack + shelf
                # table name
                tableName = "reg_" + str(rack) + '_' + str(shelf)
                # now the SQL
                sql += dataTemplate.format(
                    tableName,
                    stName,  # table name
                    rack,
                    shelf,
                    barcode,  # tags
                    Database.getNextTick(),
                    temperature,
                    pressure,
                    'xxx')  # values
                lastRack = rack
            self.execSql(sql)
        Logging.info("Last Rack: {}".format(lastRack))
Ejemplo n.º 7
0
 def execute(self):
     '''
     Actually execute the benchmark
     '''
     Logging.warning("Unexpected execution")