/clock rate is lower than set in ROS2 Gazebo
I changed publish_rate and /clock rate was changed successfully, but the rate is lower than set. For example, when I changed it to 1000Hz, which can be achieved in ROS Noetic, the result shows:
average rate: 683.508
min: 0.001s max: 0.003s std dev: 0.00051s window: 686
average rate: 663.025
min: 0.000s max: 0.004s std dev: 0.00051s window: 1329
average rate: 657.239
min: 0.000s max: 0.004s std dev: 0.00051s window: 1976
average rate: 649.790
min: 0.000s max: 0.004s std dev: 0.00052s window: 2604
average rate: 649.542
min: 0.000s max: 0.007s std dev: 0.00053s window: 3253
average rate: 642.903
min: 0.000s max: 0.007s std dev: 0.00053s window: 3863
And changing to 500hz gets a result about 400Hz, changing to 100Hz gets a result about 95Hz.
This problem may lead to another problem that other publisher's rate is lower too. For example, I created a publisher with 100Hz, but it published at a lower rate. And /clock rate is lower, the publisher's rate is lower too.
So how to solve this problem? All programs written in C++. Thanks!