int DedupFS::Release(const char *path, struct fuse_file_info *fileInfo) { printf("release(path=%s)\n", path); intrusive_ptr_release((file_info*)fileInfo->fh); bc->sync(); std::cout << "Sqlite memory used: " << sqlite3_memory_highwater(true) << std::endl; return 0; }
SWIGEXPORT jlong JNICALL Java_com_almworks_sqlite4java__1SQLiteSwiggedJNI_sqlite3_1memory_1highwater(JNIEnv *jenv, jclass jcls, jint jarg1) { jlong jresult = 0 ; int arg1 ; sqlite3_int64 result; (void)jenv; (void)jcls; arg1 = (int)jarg1; result = (sqlite3_int64)sqlite3_memory_highwater(arg1); jresult = (jlong)result; return jresult; }
void print_mem_stats(void) { uint64_t sqlite3_highwater, sqlite3_memused; printf("Duperemove memory usage statistics:\n"); show_allocs_file_block(); show_allocs_dupe_blocks_list(); show_allocs_dupe_extents(); show_allocs_extent(); show_allocs_filerec(); show_allocs_filerec_token(); show_allocs_file_hash_head(); show_allocs_find_dupes_cmp(); sqlite3_highwater = sqlite3_memory_highwater(0); sqlite3_memused = sqlite3_memory_used(); printf("Sqlite3 used: %"PRIu64" highwater: %"PRIu64"\n", sqlite3_memused, sqlite3_highwater); }
int exec_sql_list ( sqlite3 *db, const char **sqls ) { VERBOSE_PRINTF("exec_sql_list()\n"); int ret = 0; char *zErrMsg = 0; for ( int i = 0; sqls[i]; i++ ) { printf("sqls[%d] : %s\n", i, sqls[i]); ret = exec_sql ( db, sqls[i] ); if ( ret != SQLITE_OK ) { printf ( "exec_sql error: ret=%d\n", ret); sqlite3_free ( zErrMsg ); break; } //paf::thread::Sleep(1000); } printf("sqlite3_memory_highwater(): %lld\n", sqlite3_memory_highwater(true)); return ret; }
int main ( int argc, char **argv ) { int ret = check_args(argc, argv); if (ret) { printf("invalid argument error!\n"); return -1; } if (new_db) { unlink(db_name); } soft_heap_limit = sqlite3_soft_heap_limit64(soft_heap_limit); if ( soft_heap_limit < 0 ) { ret = soft_heap_limit; printf("sqlite3_soft_heap_limit() error: %x", ret); } else { printf("sqlite3_soft_heap_limit64(): prev: %ld (byte) is set to: %lld (byte).\n", soft_heap_limit, sqlite3_soft_heap_limit64(-1)); } sqlite3 *db = NULL; ret = sqlite3_open_v2 (db_name, &db, SQLITE_OPEN_CREATE|SQLITE_OPEN_READWRITE, NULL); if ( ret != SQLITE_OK ) { printf ( "Can't open database: %s\n", sqlite3_errmsg ( db ) ); return -1; } if (new_db) { // create table, transaction is useful for speed optimization printf("== execute sql_create_table ==\n"); exec_sql_list_in_transaction(db, sql_create_table); } else { printf("== use existing db: %s ==\n", db_name); } int sql_count = 0; int trans_count = 0; uint64_t total_time = 0; int64_t max_highwater = 0; uint64_t total_highwater = 0; do { uint64_t start_time = sceKernelGetProcessTime(); ret = start_transaction(db); if (ret) { printf("start_transaction() err: %x\n", ret); break; } int trans_sql_count = 0; trans_count++; do { fill_sql(sql_count); ret = exec_sql(db, sql_buf); if (ret) { break; } sql_count++; trans_sql_count++; } while (sql_count < total_sql_num && trans_sql_count < max_sql_in_trans); ret = end_transaction(db, ret); if (ret) { printf("end_transaction() err: %x\n", ret); break; } uint64_t end_time = sceKernelGetProcessTime(); total_time += end_time - start_time; printf("[%d] th transaction is end. operated sql num: %d, time: %lu (us)", trans_count, sql_count, end_time - start_time); printf("\t: sqlite3_memory_used(): %lld", sqlite3_memory_used()); int64_t highwater = sqlite3_memory_highwater(true); if (max_highwater < highwater) { max_highwater = highwater; } total_highwater += highwater; printf("\t: sqlite3_memory_highwater(true): %ld\n", highwater); } while (sql_count < total_sql_num); printf("operated sql count: %d, transaction count: %d\n", sql_count, trans_count); printf("total elapsed time: %lu (us)\n", total_time); if (trans_count != 0) { printf("maximum memory highwater: %ld, average high water / transaction: %lu\n", max_highwater, total_highwater / trans_count); } /* // select const char *sql_select[] = { "SELECT * FROM tbl1;", // select all "SELECT id, c1_int FROM tbl1 WHERE 1 < id;", // select 1 < id NULL, // terminater }; printf("\n== execute sql_select ==\n"); exec_sql(db, sql_select); */ sqlite3_close ( db ); return 0; }
DLL_FUNCTION(int64_t*) BU_SQLite_Memory_Highwater(int32_t bReset) { #pragma comment(linker, "/EXPORT:BU_SQLite_Memory_Highwater=_BU_SQLite_Memory_Highwater@4") return new int64_t(sqlite3_memory_highwater(bReset)); }