Skip to content

処理時間を計測する #9

Open

Description

@ShotaAk

計測方法

  auto start_time = micros();
  M5.update();
  M5_LOGI("elapsed time [us]:%d", micros() - start_time);

Activity

  1. ShotaAk commented on Sep 30, 2023

    @ShotaAk
    ContributorAuthor

    M5.update() : 約 11.5 usec

      auto start_time = micros();
      M5.update();
      M5_LOGI("elapsed time [us]:%d", micros() - start_time);
  2. ShotaAk commented on Sep 30, 2023

    @ShotaAk
    ContributorAuthor

    コマンド受信(データがないとき): 58 ~ 68 usec

      auto start_time = micros();
      if(g_receiver.receive()) {
        // M5_LOGD("Received command!");
      }
      M5_LOGI("elapsed time:%d", micros() - start_time);
  3. ShotaAk commented on Sep 30, 2023

    @ShotaAk
    ContributorAuthor

    I2Cのデータ送信(100kHz):819 ~ 827 usec

      auto start_time = micros();
      const unsigned char SLAVE_ADDR = 0x54;
      Wire1.beginTransmission(SLAVE_ADDR);
      Wire1.write(send_data, DATA_SIZE);
      
      if(Wire1.endTransmission() == 0) {
        // M5_LOGI("Sent command!");
      } else {
        M5_LOGD("Failed to send command!");
      }
      M5_LOGI("elapsed time:%d", micros() - start_time);
  4. ShotaAk commented on Sep 30, 2023

    @ShotaAk
    ContributorAuthor

    loop関数:880 ~ 910 usec

    i2cのクロックを400kHzに変更後:350 ~ 360 usec

    unsigned long start_time = 0;
    void loop() {
      M5_LOGI("elapsed time:%d", micros() - start_time);
      start_time = micros();
  5. ShotaAk commented on Sep 30, 2023

    @ShotaAk
    ContributorAuthor

    I2Cのデータ送信(400kHz):270 ~ 273 usec

      Wire1.begin(M5.In_I2C.getSDA(), M5.In_I2C.getSCL(), 400000);
    
      auto start_time = micros();
      const unsigned char SLAVE_ADDR = 0x54;
      Wire1.beginTransmission(SLAVE_ADDR);
      Wire1.write(send_data, DATA_SIZE);
      
      if(Wire1.endTransmission() == 0) {
        // M5_LOGI("Sent command!");
      } else {
        M5_LOGD("Failed to send command!");
      }
      M5_LOGI("elapsed time:%d", micros() - start_time);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions