传说中的 oltp.lua 脚本
来源:互联网 发布:淘宝的优势和劣势 编辑:程序博客网 时间:2024/05/16 11:56
这几天,用sysbench测试下mysql的性能,对于这个工具,测试脚本到底是如何写的,非常好奇,就把这个脚本在github上找出来,并给贴出来了。
pathtest = string.match(test, "(.*/)") or ""dofile(pathtest .. "common.lua")function thread_init(thread_id) set_vars() if (((db_driver == "mysql") or (db_driver == "attachsql")) and mysql_table_engine == "myisam") then begin_query = "LOCK TABLES sbtest WRITE" commit_query = "UNLOCK TABLES" else begin_query = "BEGIN" commit_query = "COMMIT" endendfunction event(thread_id) local rs local i local table_name local range_start local c_val local pad_val local query table_name = "sbtest".. sb_rand_uniform(1, oltp_tables_count) if not oltp_skip_trx then db_query(begin_query) end for i=1, oltp_point_selects do rs = db_query("SELECT c FROM ".. table_name .." WHERE id=" .. sb_rand(1, oltp_table_size)) end for i=1, oltp_simple_ranges do range_start = sb_rand(1, oltp_table_size) rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1) end for i=1, oltp_sum_ranges do range_start = sb_rand(1, oltp_table_size) rs = db_query("SELECT SUM(K) FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1) end for i=1, oltp_order_ranges do range_start = sb_rand(1, oltp_table_size) rs = db_query("SELECT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1 .. " ORDER BY c") end for i=1, oltp_distinct_ranges do range_start = sb_rand(1, oltp_table_size) rs = db_query("SELECT DISTINCT c FROM ".. table_name .." WHERE id BETWEEN " .. range_start .. " AND " .. range_start .. "+" .. oltp_range_size - 1 .. " ORDER BY c") end if not oltp_read_only then for i=1, oltp_index_updates do rs = db_query("UPDATE " .. table_name .. " SET k=k+1 WHERE id=" .. sb_rand(1, oltp_table_size)) end for i=1, oltp_non_index_updates do c_val = sb_rand_str("###########-###########-###########-###########-###########-###########-###########-###########-###########-###########") query = "UPDATE " .. table_name .. " SET c='" .. c_val .. "' WHERE id=" .. sb_rand(1, oltp_table_size) rs = db_query(query) if rs then print(query) end end i = sb_rand(1, oltp_table_size) rs = db_query("DELETE FROM " .. table_name .. " WHERE id=" .. i) c_val = sb_rand_str([[###########-###########-###########-###########-###########-###########-###########-###########-###########-###########]]) pad_val = sb_rand_str([[###########-###########-###########-###########-###########]]) rs = db_query("INSERT INTO " .. table_name .. " (id, k, c, pad) VALUES " .. string.format("(%d, %d, '%s', '%s')",i, sb_rand(1, oltp_table_size) , c_val, pad_val)) end -- oltp_read_only if not oltp_skip_trx then db_query(commit_query) endend
里面测试内容大概是线程和建表、查询、更改、删表的操作。如果没有找到脚本的人可以看看,个人没有学过lua的语法
PS:当时脑残的百度、google到处去搜这个脚本文件。后面才从某个网页发现是由某个人写的,并且提到了github。突然发现为啥不从github上去找找勒,果然一找就有。 1 0
- 传说中的 oltp.lua 脚本
- oltp.lua
- sysbench使用及自定义oltp测试lua脚本
- sysbench使用及自定义oltp测试lua脚本
- Mac 运行sh文件,也就是传说中的shell脚本
- LUA脚本在游戏中的应用场合
- unity3d中的lua脚本异常捕获
- OLTP
- OLTP
- OLTP
- OLTP
- lua脚本
- LUA脚本
- Lua脚本
- Lua 脚本
- LUA 脚本
- 导出C++中的类到Lua脚本中的经历
- 导出C++中的类到Lua脚本中的经历收藏
- Android 获取系统时间的时间戳
- 3.4 mymalloc.c:内存管理
- ssh 慢慢积累
- 被误读的诸葛亮
- 浅谈生产车间该如何推行6S管理
- 传说中的 oltp.lua 脚本
- 微信公众平台开发3-Https请求的封装
- log4cxx在ubuntu14.04中编译
- 显示、隐藏NavigationBar(虚拟按键)
- plsql无法中文条件查询
- java多线程之Phaser
- 3.5 watchdog.c:计时器
- iOS中的加密:MD5
- Word备忘