Beispiel #1
0
def main():
    file = open(
        "DATABASES_bench_result" +
        str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")),
        "w",
    )

    file.write("Benchmarks are made with cpu :\n")
    file.write(cpuinfo.get_cpu_info()["brand"] + "\n\n")

    for idx, query in enumerate([query1, query6, query7, query9]):
        file.write(
            "Query {0} :\n".format(str(idx + 1)) + query +
            "\n----------------------------------------------------------\n\n")

    sqlalchemy_uri = os.environ.get("SQLALCHEMY_DATABASE_URI", "sqlite://")
    db = urlparse(sqlalchemy_uri).path.replace("/", "")
    engine = sqlalchemy.create_engine(sqlalchemy_uri)
    mdx_engine = MdxEngine(sqla_engine=engine, source_type="db")
    mdx_engine.load_cube(cube_name=db if db else "main",
                         fact_table_name="facts")
    wsgi_application = get_wsgi_application(mdx_engine)

    server = WSGIServer(application=wsgi_application, host=HOST, port=PORT)

    server.start()

    for config_file in os.listdir(os.path.join(os.getcwd(),
                                               "db_config_files")):

        dbms = str(config_file.split("_")[0])

        try:
            copy_2_olapy_dir(config_file)

            # to refresh cubes from database

            provider = xmla.XMLAProvider()
            conn = provider.connect(location=server.url)

            mbench = MicBench()
            t = PrettyTable(
                ["Query", "{0} - olapy execution time".format(dbms)])

            for idx, query in enumerate([query1, query6, query7, query9]):

                if dbms.upper() in ["POSTGRES", "ORACLE"]:
                    query = fix_query_lowercase_db(query)
                t.add_row([
                    "Query" + str(idx + 1),
                    str(mbench.bench(conn, query, CUBE_NAME))
                ])

            file.write(str(t) + "\n\n")
        except XMLAException:
            type, value, traceback = sys.exc_info()
            print("Error opening %s" % (value))
            print("Can't connect to {0} database".format(dbms))
    server.stop()
Beispiel #2
0
def main():
    file = open(
        "bench_result" +
        str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")), "w")
    gen = CubeGen(number_dimensions=3, rows_length=1000, columns_length=5)
    gen.generate_csv(gen.generate_cube(3, 1000))
    mbench = MicBench()
    file.write("Benchmarks are made with cpu :\n")
    file.write(cpuinfo.get_cpu_info()["brand"] + "\n\n")

    mdx_engine = MdxEngine()
    mdx_engine.load_cube(CUBE_NAME)
    wsgi_application = get_wsgi_application(mdx_engine)
    server = WSGIServer(application=wsgi_application, host=HOST, port=PORT)
    server.start()
    provider = xmla.XMLAProvider()
    conn = provider.connect(location=server.url)
    olapy_query_execution_bench(file, mbench, conn, mdx_engine)
    olapy_vs_mondrian(file, mbench, conn)
    olapy_vs_iccube(file, mbench, conn)
    olapy_profile(file)
    gen.remove_temp_cube()
    file.close()
    server.stop()