-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
918 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wsign-compare -pedantic -Werror") | ||
|
||
execute_process(COMMAND echo "int main() { return 0;}" OUTPUT_FILE test.cpp) | ||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -std=c++17 test.cpp -o a.out RESULT_VARIABLE CPP17_READY_RESULT) | ||
execute_process(COMMAND rm test.cpp OUTPUT_QUIET ERROR_QUIET) | ||
execute_process(COMMAND rm a.out OUTPUT_QUIET ERROR_QUIET) | ||
|
||
if ("${CPP17_READY_RESULT}" STREQUAL "0") | ||
set(CPP17_READY 1) | ||
else() | ||
set(CPP17_NOT_READY 1) | ||
endif() | ||
|
||
if (CPP17_READY) | ||
message(STATUS "compiler supports -std=c++17") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17") | ||
else() | ||
message(STATUS "compiler does not support -std=c++17, using -std=c++1z instead") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++1z") | ||
endif() | ||
|
||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-ignored-optimization-argument") | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-string-literal-operator-template") | ||
endif() | ||
|
||
find_program(CCACHE_FOUND ccache) | ||
|
||
if(CCACHE_FOUND) | ||
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache) | ||
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) | ||
endif() | ||
|
||
find_package(Boost COMPONENTS coroutine context system thread REQUIRED) | ||
include_directories(SYSTEM "${Boost_INCLUDE_DIRS}") | ||
|
||
find_package(PostgreSQL) | ||
include_directories(SYSTEM "${PostgreSQL_INCLUDE_DIRS}") | ||
|
||
set(LIBRARIES | ||
pthread | ||
${Boost_LIBRARIES} | ||
${PostgreSQL_LIBRARIES} | ||
) | ||
|
||
add_executable(ozo_benchmark ozo_benchmark.cpp) | ||
target_link_libraries(ozo_benchmark ${LIBRARIES}) | ||
|
||
add_executable(ozo_benchmark_performance performance.cpp) | ||
target_link_libraries(ozo_benchmark_performance ${LIBRARIES}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import asyncio | ||
import aiopg | ||
import time | ||
import sys | ||
|
||
|
||
def main(): | ||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(run()) | ||
|
||
|
||
async def run(): | ||
total_rows = [0] | ||
start = time.monotonic() | ||
await asyncio.gather(*[reuse_connection(total_rows) for _ in range(CONNECTIONS)]) | ||
finish = time.monotonic() | ||
print('read %s rows, %.3f row/sec' % (total_rows[0], total_rows[0] / (finish - start))) | ||
|
||
|
||
async def reuse_connection(total_rows): | ||
conn = await aiopg.connect(sys.argv[1]) | ||
async with conn.cursor() as cur: | ||
while total_rows[0] < 10000000: | ||
await cur.execute(QUERY, parameters=(-1, True)) | ||
values = [] | ||
async for row in cur: | ||
values.append(row) | ||
total_rows[0] += len(values) | ||
await conn.close() | ||
|
||
|
||
CONNECTIONS = 8 | ||
QUERY = ''' | ||
SELECT typname, typnamespace, typowner, typlen, typbyval, typcategory, | ||
typispreferred, typisdefined, typdelim, typrelid, typelem, typarray | ||
FROM pg_type | ||
WHERE typtypmod = %s AND typisdefined = %s | ||
''' | ||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import asyncio | ||
import asyncpg | ||
import time | ||
import sys | ||
|
||
|
||
def main(): | ||
loop = asyncio.get_event_loop() | ||
loop.run_until_complete(run()) | ||
|
||
|
||
async def run(): | ||
total_rows = [0] | ||
start = time.monotonic() | ||
await asyncio.gather(*[reuse_connection(total_rows) for _ in range(CONNECTIONS)]) | ||
finish = time.monotonic() | ||
print('read %s rows, %.3f row/sec' % (total_rows[0], total_rows[0] / (finish - start))) | ||
|
||
|
||
async def reuse_connection(total_rows): | ||
conn = await asyncpg.connect(sys.argv[1]) | ||
while total_rows[0] < 10000000: | ||
values = await conn.fetch(QUERY, -1, True) | ||
total_rows[0] += len(values) | ||
await conn.close() | ||
|
||
|
||
CONNECTIONS = 8 | ||
QUERY = ''' | ||
SELECT typname, typnamespace, typowner, typlen, typbyval, typcategory, | ||
typispreferred, typisdefined, typdelim, typrelid, typelem, typarray | ||
FROM pg_type | ||
WHERE typtypmod = $1 AND typisdefined = $2 | ||
''' | ||
|
||
if __name__ == '__main__': | ||
main() |
Oops, something went wrong.