Skip to content

Instantly share code, notes, and snippets.

@yoku0825
Last active August 26, 2020 08:27
Show Gist options
  • Save yoku0825/1f5127749cd638f50e13778b48f57cd0 to your computer and use it in GitHub Desktop.
Save yoku0825/1f5127749cd638f50e13778b48f57cd0 to your computer and use it in GitHub Desktop.
認証プラグインだけベンチとかやったことないですがこれでできそう…?
-- 下準備
-- 1. パスワードを空っぽにすると認証機構がバイパスされたりするので1文字でもいいのでパスワードは入れる
-- 2. mysqlslapはデフォルトスキーマ `mysqlslap` にアクセスしようとして回避できないのでどこか指定する
mysql80 2998> CREATE USER yoku0825_native IDENTIFIED WITH mysql_native_password BY 'yoku0825';
Query OK, 0 rows affected (0.00 sec)
mysql80 2998> GRANT SELECT ON mysqlslap.* TO yoku0825_native;
Query OK, 0 rows affected (0.00 sec)
mysql80 2998> CREATE USER yoku0825_caching IDENTIFIED WITH caching_sha2_password BY 'yoku0825';
Query OK, 0 rows affected (0.01 sec)
mysql80 2998> GRANT SELECT ON mysqlslap.* TO yoku0825_caching;
Query OK, 0 rows affected (0.00 sec)
mysql80 2998> CREATE USER yoku0825_sha256 IDENTIFIED WITH sha256_password BY 'yoku0825';
Query OK, 0 rows affected (0.01 sec)
mysql80 2998> GRANT SELECT ON mysqlslap.* TO yoku0825_sha256;
Query OK, 0 rows affected (0.00 sec)
### 実行はシェルから
### --detatch=1 で1クエリーごとに接続/切断を発生させる
### --query="SELECT 1" は認証方法に関わらずO(1)な時間で結果を返す
### mysql_native_password
$ mysqlslap --no-defaults -h127.0.0.1 -P64080 -uyoku0825_native --password=yoku0825 \
--number-of-queries=100 --iterations=5 \
--detach=1 --ssl-mode=DISABLE --query="SELECT 1"
mysqlslap: [Warning] Using a password on the command line interface can be insecure.
Benchmark
Average number of seconds to run all queries: 1.153 seconds
Minimum number of seconds to run all queries: 1.049 seconds
Maximum number of seconds to run all queries: 1.315 seconds
Number of clients running queries: 1
Average number of queries per client: 100
### sha256_password
$ mysqlslap --no-defaults -h127.0.0.1 -P64080 -uyoku0825_sha256 --password=yoku0825 \
--number-of-queries=100 --iterations=5 \
--detach=1 --ssl-mode=DISABLE --query="SELECT 1"
mysqlslap: [Warning] Using a password on the command line interface can be insecure.
Benchmark
Average number of seconds to run all queries: 1.415 seconds
Minimum number of seconds to run all queries: 1.396 seconds
Maximum number of seconds to run all queries: 1.453 seconds
Number of clients running queries: 1
Average number of queries per client: 100
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment