【SysBench】OLTP 基准测试示例

前言

本文采用 MySQL 沙盒实例作为测试目标,使用 sysbench-1.20 对其做 OLTP 基准测试。

有关 MySQL 沙盒的更多信息,请参阅 玩转 MySQL Shell 沙盒实例,【MySQL Shell】6.8 AdminAPI MySQL 沙盒 。


1、部署一个 MySQL 沙盒实例

使用 mysqlsh 部署一个 MySQL 沙盒实例用于测试 OLTP 。

 MySQL  JS > dba.deploySandboxInstance(3310);
A new MySQL sandbox instance will be created on this host in 
/root/mysql-sandboxes/3310

Warning: Sandbox instances are only suitable for deploying and 
running on your local machine for testing purposes and are not 
accessible from external networks.

Please enter a MySQL root password for the new instance: ********

Deploying new MySQL instance...

Instance localhost:3310 successfully deployed and started.
Use shell.connect('root@localhost:3310') to connect to the instance.

2、创建 sysbench oltp 测试的基础配置文件

为什么要使用配置文件?方便快捷啊!配置文件可以简化操作,省着在命令行中指定这些参数时至少还要多打 -- 和空格。如果一些参数可以复用,建议创建一个配置文件。

$ cat mysql-sb.cnf 
threads=2
time=600

db-driver=mysql
mysql-host=localhost
mysql-port=3310
mysql-socket=/root/mysql-sandboxes/3310/sandboxdata/mysqld.sock
mysql-user=root
mysql-password=Ro123ot$
mysql-db=sbtest

在创建时读者可能遇到一个问题,在配置文件中指定诸如 tables 选项时不生效,并且会报 Unknown argument type: 0 。而在命令行中指定时则有效。原因是什么呢?

因为这个参数是 Lua 脚本的参数,而不是 sysbench 这个二进制可执行文件的参数!

所以应该在命令行中使用诸如 --tables=N 这样的 Lua 脚本参数来测试。

3、准备测试数据

笔者准备了 100 个包含 10000 行数据的测试表,库名和表名都是用默认值。

$ sysbench --config-file=mysql-sb.cnf --tables=100 oltp_common prepare

注意此阶段的屏幕打印信息,多线程时可能出现争用,导致部分表未创建成功,或写入的数据不全。

sbtest6 创建失败报错:
在这里插入图片描述

计划创建 100 张表,实际只创建了 53 个,上面的 sbtest6 表虽然最后创建成功了,但插入的数据不全。

在这里插入图片描述

在这里插入图片描述

4、运行测试

1) oltp_read_write

建议先对支持 prewarm 选项的 Lua 脚本使用 prewarm 选项,以预热数据到内存,提高性能。

$ sysbench --config-file=mysql-sb.cnf --tables=100 oltp_read_write.lua prewarm

因输出过长,以下仅截取部分信息。

预热后:

$ sysbench --config-file=mysql-sb.cnf --tables=100 oltp_read_write.lua run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 2
Initializing random number generator from current time


Initializing worker threads...

Threads started!

SQL statistics:
    queries performed:
        read:                            2272046
        write:                           530149
        other:                           443585
        total:                           3245780
    transactions:                        162289 (270.47 per sec.)
    queries:                             3245780 (5409.35 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          600.0289s
    total number of events:              162289

Latency (ms):
         min:                                    4.40
         avg:                                    7.39
         max:                                  427.68
         95th percentile:                       10.09
         sum:                              1199185.78

Threads fairness:
    events (avg/stddev):           81144.5000/31.50
    execution time (avg/stddev):   599.5929/0.00

未预热,同时使用周期报告来每 5 秒生成一次报告信息:

$ sysbench --config-file=mysql-sb.cnf --tables=100 oltp_read_write run --report-interval=5
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 2
Report intermediate results every 5 second(s)
Initializing random number generator from current time


Initializing worker threads...

Threads started!

[ 5s ] thds: 2 tps: 137.01 qps: 2747.56 (r/w/o: 1923.71/549.43/274.42) lat (ms,95%): 23.52 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 2 tps: 199.67 qps: 3993.69 (r/w/o: 2795.44/798.90/399.35) lat (ms,95%): 14.73 err/s: 0.00 reconn/s: 0.00
[ 15s ] thds: 2 tps: 204.00 qps: 4080.05 (r/w/o: 2856.03/816.01/408.00) lat (ms,95%): 12.52 err/s: 0.00 reconn/s: 0.00
...
[ 590s ] thds: 2 tps: 285.00 qps: 5698.37 (r/w/o: 3989.18/1139.19/570.00) lat (ms,95%): 9.06 err/s: 0.00 reconn/s: 0.00
[ 595s ] thds: 2 tps: 285.80 qps: 5714.78 (r/w/o: 3999.39/1144.00/571.40) lat (ms,95%): 9.06 err/s: 0.00 reconn/s: 0.00
[ 600s ] thds: 2 tps: 281.97 qps: 5641.39 (r/w/o: 3949.97/1127.28/564.14) lat (ms,95%): 9.22 err/s: 0.00 reconn/s: 0.00
SQL statistics:
    queries performed:
        read:                            2126824
        write:                           607664
        other:                           303832
        total:                           3038320
    transactions:                        151916 (253.18 per sec.)
    queries:                             3038320 (5063.66 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          600.0218s
    total number of events:              151916

Latency (ms):
         min:                                    4.70
         avg:                                    7.89
         max:                                 1579.23
         95th percentile:                        9.91
         sum:                              1199355.27

Threads fairness:
    events (avg/stddev):           75958.0000/101.00
    execution time (avg/stddev):   599.6776/0.00

2) oltp_point_select.lua

注意,.lua 后缀加不加都行。

$ sysbench --config-file=mysql-sb.cnf --tables=100 oltp_point_select.lua run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 2
Report intermediate results every 5 second(s)
Initializing random number generator from current time


Initializing worker threads...

Threads started!
[ 5s ] thds: 2 tps: 13309.18 qps: 13309.18 (r/w/o: 13309.18/0.00/0.00) lat (ms,95%): 0.21 err/s: 0.00 reconn/s: 0.00
[ 10s ] thds: 2 tps: 12990.77 qps: 12990.77 (r/w/o: 12990.77/0.00/0.00) lat (ms,95%): 0.22 err/s: 0.00 reconn/s: 0.00
[ 15s ] thds: 2 tps: 13777.54 qps: 13777.54 (r/w/o: 13777.54/0.00/0.00) lat (ms,95%): 0.20 err/s: 0.00 reconn/s: 0.00
...
[ 590s ] thds: 2 tps: 13479.94 qps: 13479.94 (r/w/o: 13479.94/0.00/0.00) lat (ms,95%): 0.20 err/s: 0.00 reconn/s: 0.00
[ 595s ] thds: 2 tps: 13402.69 qps: 13402.69 (r/w/o: 13402.69/0.00/0.00) lat (ms,95%): 0.20 err/s: 0.00 reconn/s: 0.00
[ 600s ] thds: 2 tps: 13573.04 qps: 13573.04 (r/w/o: 13573.04/0.00/0.00) lat (ms,95%): 0.20 err/s: 0.00 reconn/s: 0.00
SQL statistics:
    queries performed:
        read:                            8165259
        write:                           0
        other:                           0
        total:                           8165259
    transactions:                        8165259 (13608.60 per sec.)
    queries:                             8165259 (13608.60 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          600.0052s
    total number of events:              8165259

Latency (ms):
         min:                                    0.12
         avg:                                    0.15
         max:                                   48.51
         95th percentile:                        0.20
         sum:                              1189126.95

Threads fairness:
    events (avg/stddev):           4082629.5000/4029.50
    execution time (avg/stddev):   594.5635/0.01

3) oltp_write_only.lua

上面设置的 report-interval 每 5 秒报告一次太频繁了,笔者目的是为了演示 sysbench 的用法,因而选择后面不再报告了。

此外,这个测试我在命令行增加了开启直方图的参数 --histogram=on ,来看一下效果吧!

$ sysbench --config-file=mysql-sb.cnf --tables=100 oltp_write_only.lua run --histogram=on
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 2
Initializing random number generator from current time


Initializing worker threads...

Threads started!

Latency histogram (values are in milliseconds)
       value  ------------- distribution ------------- count
       1.759 |                                         1
       1.824 |                                         1
       1.857 |                                         5
       1.891 |                                         11
       1.925 |                                         22
       1.960 |                                         69
       1.996 |                                         149
       2.032 |                                         201
       2.069 |*                                        335
       2.106 |*                                        557
       2.145 |**                                       947
       2.184 |***                                      1327
       2.223 |****                                     1896
       2.264 |*****                                    2608
       2.305 |*******                                  3578
       2.347 |**********                               4687
       2.389 |*************                            6072
       2.433 |****************                         7844
       2.477 |********************                     9856
       2.522 |************************                 11344
       2.568 |**************************               12441
       2.615 |*****************************            13762
       2.662 |*******************************          15034
       2.710 |**********************************       16514
       2.760 |*************************************    17735
       2.810 |**************************************** 19185
       2.861 |**************************************** 19258
       2.913 |***************************************  18997
       2.966 |**************************************   18409
       3.020 |***********************************      17069
       3.075 |*********************************        15689
       3.130 |*******************************          14864
       3.187 |****************************             13647
       3.245 |**************************               12369
       3.304 |***********************                  11086
       3.364 |********************                     9858
       3.425 |******************                       8680
       3.488 |****************                         7786
       3.551 |**************                           6774
       3.615 |************                             5633
       3.681 |**********                               4828
       3.748 |********                                 3991
       3.816 |*******                                  3428
       3.885 |******                                   2853
       3.956 |*****                                    2360
       4.028 |****                                     1948
       4.101 |***                                      1648
       4.176 |***                                      1346
       4.252 |**                                       1082
       4.329 |**                                       1005
       4.407 |**                                       796
       4.487 |*                                        679
       4.569 |*                                        629
       4.652 |*                                        548
       4.737 |*                                        473
       4.823 |*                                        498
       4.910 |*                                        453
       4.999 |*                                        462
       5.090 |*                                        456
       5.183 |*                                        448
       5.277 |*                                        458
       5.373 |*                                        499
       5.470 |*                                        478
       5.570 |*                                        517
       5.671 |*                                        481
       5.774 |*                                        544
       5.879 |*                                        561
       5.986 |*                                        546
       6.095 |*                                        568
       6.205 |*                                        549
       6.318 |*                                        570
       6.433 |*                                        529
       6.550 |*                                        575
       6.669 |*                                        496
       6.790 |*                                        463
       6.913 |*                                        451
       7.039 |*                                        418
       7.167 |*                                        407
       7.297 |*                                        355
       7.430 |*                                        353
       7.565 |*                                        308
       7.702 |*                                        266
       7.842 |*                                        259
 
SQL statistics:
    queries performed:
        read:                            0
        write:                           1480184
        other:                           740092
        total:                           2220276
    transactions:                        370046 (616.73 per sec.)
    queries:                             2220276 (3700.37 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          600.0123s
    total number of events:              370046

Latency (ms):
         min:                                    1.76
         avg:                                    3.24
         max:                                 1266.80
         95th percentile:                        4.41
         sum:                              1198670.01

Threads fairness:
    events (avg/stddev):           185023.0000/8.00
    execution time (avg/stddev):   599.3350/0.00

输出信息也太长了,以上仅截取重要的直方图部分。

4) oltp_delete.lua

$ sysbench --config-file=mysql-sb.cnf --tables=100 oltp_delete.lua run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 2
Initializing random number generator from current time


Initializing worker threads...

Threads started!

SQL statistics:
    queries performed:
        read:                            0
        write:                           312795
        other:                           3073107
        total:                           3385902
    transactions:                        3385902 (5643.06 per sec.)
    queries:                             3385902 (5643.06 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          600.0094s
    total number of events:              3385902

Latency (ms):
         min:                                    0.11
         avg:                                    0.35
         max:                                  774.49
         95th percentile:                        1.58
         sum:                              1194234.55

Threads fairness:
    events (avg/stddev):           1692951.0000/195.00
    execution time (avg/stddev):   597.1173/0.01

5) oltp_insert.lua

$ sysbench --config-file=mysql-sb.cnf --tables=100 oltp_insert.lua run --histogram=on
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 2
Initializing random number generator from current time


Initializing worker threads...

Threads started!

Latency histogram (values are in milliseconds)
       value  ------------- distribution ------------- count
       0.872 |                                         1
       0.888 |                                         3
       0.904 |                                         7
       0.920 |                                         12
       0.937 |                                         43
       0.954 |                                         73
       0.971 |                                         186
       0.989 |                                         359
       1.007 |*                                        548
       1.025 |*                                        640
       1.044 |*                                        829
       1.063 |*                                        1277
       1.082 |***                                      2289
       1.102 |****                                     3604
       1.122 |******                                   4984
       1.142 |*******                                  6073
       1.163 |*********                                7463
       1.184 |**********                               8819
       1.205 |***********                              9559
       1.227 |*************                            10751
       1.250 |***************                          12863
       1.272 |*******************                      15982
       1.295 |**********************                   19122
       1.319 |*************************                21523
       1.343 |**************************               22617
       1.367 |*****************************            24922
       1.392 |**********************************       29320
       1.417 |**************************************   32289
       1.443 |**************************************   32792
       1.469 |***************************************  33521
       1.496 |**************************************** 34324
       1.523 |**************************************   32975
       1.551 |***************************************  33122
       1.579 |**************************************   32907
       1.608 |*************************************    31956
       1.637 |************************************     30909
       1.667 |**********************************       29239
       1.697 |********************************         27315
       1.728 |*****************************            25275
       1.759 |**************************               22348
       1.791 |**********************                   18824
       1.824 |*******************                      16152
       1.857 |*****************                        14749
       1.891 |***************                          13044
       1.925 |*************                            10862
       1.960 |***********                              9120
       1.996 |*********                                7758
       2.032 |********                                 6459
       2.069 |******                                   5426
       2.106 |*****                                    4678
       2.145 |*****                                    4135
       2.184 |****                                     3500
       2.223 |****                                     3054
       2.264 |***                                      2768
       2.305 |***                                      2319
       2.347 |**                                       2034
       2.389 |**                                       1773
       2.433 |**                                       1516
       2.477 |**                                       1301
       2.522 |*                                        1070
       2.568 |*                                        954
       2.615 |*                                        755
       2.662 |*                                        675
       2.710 |*                                        631
       2.760 |*                                        492
       2.810 |*                                        451
       2.861 |      
SQL statistics:
    queries performed:
        read:                            0
        write:                           744453
        other:                           0
        total:                           744453
    transactions:                        744453 (1240.74 per sec.)
    queries:                             744453 (1240.74 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          600.0049s
    total number of events:              744453

Latency (ms):
         min:                                    0.87
         avg:                                    1.61
         max:                                  926.39
         95th percentile:                        2.11
         sum:                              1196638.09

Threads fairness:
    events (avg/stddev):           372226.5000/3.50
    execution time (avg/stddev):   598.3190/0.01

6) oltp_read_only.lua

$ sysbench --config-file=mysql-sb.cnf --tables=100 oltp_read_only.lua  run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 2
Initializing random number generator from current time


Initializing worker threads...

Threads started!

SQL statistics:
    queries performed:
        read:                            7425740
        write:                           0
        other:                           1060820
        total:                           8486560
    transactions:                        530410 (883.99 per sec.)
    queries:                             8486560 (14143.89 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          600.0137s
    total number of events:              530410

Latency (ms):
         min:                                    1.97
         avg:                                    2.26
         max:                                   54.63
         95th percentile:                        3.07
         sum:                              1198568.01

Threads fairness:
    events (avg/stddev):           265205.0000/33.00
    execution time (avg/stddev):   599.2840/0.00

7) oltp_update_index.lua

$ sysbench --config-file=mysql-sb.cnf --tables=100 oltp_update_index.lua run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 2
Initializing random number generator from current time


Initializing worker threads...

Threads started!

SQL statistics:
    queries performed:
        read:                            0
        write:                           145095
        other:                           4800953
        total:                           4946048
    transactions:                        4946048 (8243.33 per sec.)
    queries:                             4946048 (8243.33 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          600.0030s
    total number of events:              4946048

Latency (ms):
         min:                                    0.12
         avg:                                    0.24
         max:                                  259.25
         95th percentile:                        0.42
         sum:                              1192593.66

Threads fairness:
    events (avg/stddev):           2473024.0000/862.00
    execution time (avg/stddev):   596.2968/0.08

8) oltp_update_non_index.lua

$ sysbench --config-file=mysql-sb.cnf --tables=100 oltp_update_non_index.lua run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 2
Initializing random number generator from current time


Initializing worker threads...

Threads started!

SQL statistics:
    queries performed:
        read:                            0
        write:                           141508
        other:                           4686830
        total:                           4828338
    transactions:                        4828338 (8047.17 per sec.)
    queries:                             4828338 (8047.17 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          600.0022s
    total number of events:              4828338

Latency (ms):
         min:                                    0.12
         avg:                                    0.25
         max:                                  382.28
         95th percentile:                        0.44
         sum:                              1192434.24

Threads fairness:
    events (avg/stddev):           2414169.0000/3780.00
    execution time (avg/stddev):   596.2171/0.04

9) select_random_points.lua


10) select_random_ranges.lua


11) bulk_insert.lua

此测试与前面那些测试有些不同,它只会创建与线程数相同的个数的表,并且没有 talbes 参数。因此我们需要修改执行命令,先清理 sbtest1sbtest2 表的数据,然后再 prepare ,最后再 run

$ sysbench --config-file=mysql-sb.cnf bulk_insert.lua cleanup
$ sysbench --config-file=mysql-sb.cnf bulk_insert.lua prepare
$ sysbench --config-file=mysql-sb.cnf --tables=100 bulk_insert.lua run
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 2
Initializing random number generator from current time


Initializing worker threads...

Threads started!

SQL statistics:
    queries performed:
        read:                            0
        write:                           2075
        other:                           0
        total:                           2075
    transactions:                        56561449 (94080.36 per sec.)
    queries:                             2075   (3.45 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          600.9490s
    total number of events:              56561449

Latency (ms):
         min:                                    0.00
         avg:                                    0.02
         max:                                 2011.20
         95th percentile:                        0.00
         sum:                              1182530.43

Threads fairness:
    events (avg/stddev):           28280724.5000/13106.50
    execution time (avg/stddev):   591.2652/0.25

MySQL 数据库内的执行结果如下:

 MySQL  localhost:3310 ssl  sbtest  SQL > select count(*) from sbtest1;
+----------+
| count(*) |
+----------+
| 28293831 |
+----------+
1 row in set (1.7266 sec)

 MySQL  localhost:3310 ssl  sbtest  SQL > select count(*) from sbtest2;
+----------+
| count(*) |
+----------+
| 28267618 |
+----------+
1 row in set (1.8061 sec)

我们可以修改 times 参数为一个较小的值,因为没有必要批量插入 10 分钟的数据。

$ sysbench --config-file=mysql-sb.cnf bulk_insert.lua prepare --time=60
$ sysbench --config-file=mysql-sb.cnf bulk_insert.lua run --time=60
sysbench 1.0.20 (using bundled LuaJIT 2.1.0-beta2)

Running the test with following options:
Number of threads: 2
Initializing random number generator from current time


Initializing worker threads...

Threads started!

SQL statistics:
    queries performed:
        read:                            0
        write:                           190
        other:                           0
        total:                           190
    transactions:                        5722434 (94526.75 per sec.)
    queries:                             190    (3.14 per sec.)
    ignored errors:                      0      (0.00 per sec.)
    reconnects:                          0      (0.00 per sec.)

General statistics:
    total time:                          60.5316s
    total number of events:              5722434

Latency (ms):
         min:                                    0.00
         avg:                                    0.02
         max:                                 1102.79
         95th percentile:                        0.00
         sum:                               118906.30

Threads fairness:
    events (avg/stddev):           2861217.0000/0.00
    execution time (avg/stddev):   59.4532/0.19

可以看到再命令行最后指定的 --times=60 覆盖了配置文件中指定的 time=600

 MySQL  localhost:3310 ssl  sbtest  SQL > select 'sbtest1' table_name,count(*) from sbtest1 union all
                                       -> select 'sbtest1' table_name,count(*) from sbtest2;
+------------+----------+
| table_name | count(*) |
+------------+----------+
| sbtest1    |  2861217 |
| sbtest1    |  2861217 |
+------------+----------+
2 rows in set (0.4175 sec)

5、清理数据

$ sysbench --config-file=mysql-sb.cnf oltp_common.lua --tables=100 cleanup

在这里插入图片描述

6、销毁 MySQL 沙盒实例

mysqlsh 终端中执行:

 MySQL  localhost:3310 ssl  sbtest  JS > dba.stopSandboxInstance(3310)
The MySQL sandbox instance on this host in 
3310 will be stopped

Please enter the MySQL root password for the instance 'localhost:3310': ********
The active session is established to the sandbox being stopped so it's going to be closed.

Stopping MySQL instance...

Instance localhost:3310 successfully stopped.

 MySQL  JS > dba.deleteSandboxInstance(3310);

Deleting MySQL instance...

Instance localhost:3310 successfully deleted.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/482581.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

云计算 3月18号 (mysql安装及操作)

一、Mysql 1.1 MySQL数据库介绍 1.1.1 什么是数据库DB? DB的全称是database,即数据库的意思。数据库实际上就是一个文件集合,是一个存储数据的仓库,数据库是按照特定的格式把数据存储起来,用户可以对存储的数据进行…

mac 安装 nvm 【真解决问题】

前提 没有node环境已有git 下载 我用的gitee极速下载 git clone https://gitee.com/mirrors/nvm.git ~/.nvm && cd ~/.nvm && git checkout git describe --abbrev0 --tags配置 1. 配置变量 在用户的目录下新增文件 .zshrc export NVM_DIR"$HOME/…

[数据结构]二叉树(下)

一、二叉树的节点和深度关系 1.满二叉树 我们可以假设二叉树有N个节点,深度为h我们可以恒容易得到满二叉树每行的节点数,然后错位相减,算出节点与高度的关系。 2.完全二叉树 注意我这个是因为最后一行的节点数为1。 二、向上调整建堆和向下调整建堆的时…

【Node.js】CSR、SSR、SEO

SSR 和 CSR SSR (Server-Side Rendering)服务端渲染,请求数据和拼装都在服务端完成,相当于在服务端直接完成html。 而 Vue,react 等框架,是在客户端完成渲染拼接的,属于CSR(Client-Side Rende…

Linux/openEuler系统部署spring boot+vue前后端分离项目(nginx均衡代理)

Linux/openEuler系统部署spring bootvue前后端分离项目(nginx均衡代理) 1、系统环境准备,安装openjdk和nginx还有MySQL,咱们本文先连接主机mysql进行登录(linux上的mysql服务可以先不安装) 可以看我前面的…

【神经网络】得分函数,损失函数~

目录 引言 一、神经网络概述 1 定义 2 基本原理 二、得分函数 1 定义 2 应用方法 3 与神经网络 三、损失函数 1 定义 2实现方法 3 与神经网络 四、得分函数与损失函数的协同作用 1 关系 2 实际应用 六、代码事例 、总结与展望 引言 在人工智能与机…

40 openlayers setCenter 之后 绘制了Overlay 地图定位异常

前言 这是之前在 生产环境碰到的一个问题 这个其实就是 业务上一个地图点击点位展示详情, 然后再点击另外一个点位 展示详情, 切换中心店的这个过程 其主要的问题是 使用 openlayers 的 Map.View.setCenter() 了之后, 整个地图的中心点切换到了一个莫名其妙的地方 然后 经…

Linux的学习之路:2、基础指令(1)

一、ls指令 上篇文章已经说了一点点的ls指令,不过那还是不够的,这篇文章会介绍更多的指令,最起码能使用命令行进行一些简单的操作,下面开始介绍了 ls常用选项 -a 列出目录下的所有文件,包括以 . 开头的隐含文件。 -d…

3.4网安学习第三阶段第四周回顾(个人学习记录使用)

本周重点 ①CSRF跨站请求伪造 ②跨域访问 ③文件包含 ④文件上传 ⑤文件下载漏洞 ⑥XXE外部实体注入 本周主要内容 ①CSRF跨站请求伪造 一、概述: csrf: cross site request forgrey 跨站请求伪造。当攻击者不能通过常用的手段获取cookie时候,…

SQL Server 2008R2 日志文件大小设置及查询

SQL Server 2008R2 建立数据库存在日志无限增长问题,造成磁盘内存不足。本文解决这个问题,如下: 1.设置日志文件的最大大小 USE master; GO ALTER DATABASE [D_total] MODIFY FILE (NAME D_total_log, -- 日志文件的逻辑名称MAXSIZE 200…

信号处理--基于FBCSP滤波方法的运动想象分类

目录 理论 工具 方法 代码获取 理论 通用空间模式 (CSP) 算法可以用来有效构建最佳空间滤波器区分,然后实现运动想象的数据中的脑电信号的区分。然而,空间滤波器性能的好坏主要取决于其工作频带。如果脑电信号没有经过滤波或者滤波的频带范围不合适…

计算机组成原理 微程序控制器组成实验

一、实验目的 1.掌握时序产生器的组成原理。 2.掌握微程序控制器的组成原理。 3.掌握微指令格式的化简和归并。 二、实验任务 1、按实验要求连接实验台的数码开关K0-K5、按钮开关、时钟信号源和微程序控制器。注意:本次试验只做微程序控制器本身的实验&#xf…

安科瑞ANET智能物联网网关 通信管理机-安科瑞 蒋静

概述 本系列智能通信管理机是一款采用嵌入式硬件计算机平台,具有多个下行通信接口及一个或者多个上行网络接口,用于将一个目标区域内所有的智能监控/ 保护装置的通信数据整理汇总后,实时上传主站系统,完成遥信、遥测等能源数据采集…

基于Java+Spring Boot+MySQL的二手手机管理系统

末尾获取源码作者介绍:大家好,我是墨韵,本人4年开发经验,专注定制项目开发 更多项目:CSDN主页YAML墨韵 学如逆水行舟,不进则退。学习如赶路,不能慢一步。 目录 一、项目简介 二、开发技术与环…

【项目自我反思之vue的组件通信】

为什么子组件不能通过props实时接收父组件修改后动态变化的值 一、现象二、可能的原因1.响应式系统的限制2.异步更新队列3.父组件和子组件的生命周期4.子组件内部对 props 的处理 三、组件通信的几种场景(解决方案)1.子组件想修改父组件的数据2.子组件传…

Rust GUI学习 小部件系列(一):如何在iced窗口中使用颜色选择器colorpicker

注:此文适合于对rust有一些了解的朋友 iced是一个跨平台的GUI库,用于为rust语言程序构建UI界面。 前言: 本系列是iced的小部件应用介绍系列,主要介绍iced、iced_aw两个库中涉及的各种小部件的使用及实例演示。 本文所介绍的是co…

Redis入门到入坑(一)

Redis入门到入坑(一) Redis缓存入门简介Redis初始操作Redis数据存储操作 Redis常用数据类型简介String类型操作实践Hash类型应用实践List类型应用实践Set类型应用实践 Java中操作redis准备工作Jedis的应用快速入门实现RedisTemplate应用项目工程实践 Red…

嵌入式安全性基础知识-计算机系统安全知识+信息安全基础+网络安全协议-嵌入式系统设计师备考笔记

0、前言 本专栏为个人备考软考嵌入式系统设计师的复习笔记,未经本人许可,请勿转载,如发现本笔记内容的错误还望各位不吝赐教(笔记内容可能有误怕产生错误引导)。 本章的主要内容见下图: 1、计算机系统系统…

设计模式——2_6 观察者(Observer)

这世界没有一件事情是虚空而生的,站在光里,背后就会有阴影,这深夜里一片寂静,是因为你还没有听见声音 ——马良《坦白书》 文章目录 定义图纸一个例子:在RPG游戏里应对善变的天气定义元素Area & Weather 给 Area 和…

Linux--Ubuntu安装【保姆级教程】

Linux操作系统时程序员必须要学的操作系统。接下来我们就来看一下Linux操作系统是如何安装的 我们在 Vmware 虚拟机中安装 linux 系统,所以需要先安装 vmware 软件,然后再 安装 Linux 系统。 一.所需安装文件: Vmware 下载地址(现在最新版的…