Files
react-native/ReactCommon/fabric/mounting/MountingTelemetry.cpp
Valentin Shergin 4803cab8c4 Fabric: MountingTelemetry and refinments in TimeUtils
Summary: This diff implements encapsulating all time metrics in a single class for better extensibility and readability.

Reviewed By: JoshuaGross

Differential Revision: D15179835

fbshipit-source-id: 62bdf94435a0d37a87ad9bad613cc8e38043a235
2019-05-03 15:11:34 -07:00

61 lines
1.5 KiB
C++

/**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#include "MountingTelemetry.h"
#include <cassert>
#include <react/utils/TimeUtils.h>
namespace facebook {
namespace react {
void MountingTelemetry::willCommit() {
assert(commitStartTime_ == kUndefinedTime);
assert(commitEndTime_ == kUndefinedTime);
commitStartTime_ = getTime();
}
void MountingTelemetry::didCommit() {
assert(commitStartTime_ != kUndefinedTime);
assert(commitEndTime_ == kUndefinedTime);
commitEndTime_ = getTime();
}
void MountingTelemetry::willLayout() {
assert(layoutStartTime_ == kUndefinedTime);
assert(layoutEndTime_ == kUndefinedTime);
layoutStartTime_ = getTime();
}
void MountingTelemetry::didLayout() {
assert(layoutStartTime_ != kUndefinedTime);
assert(layoutEndTime_ == kUndefinedTime);
layoutEndTime_ -= getTime();
}
int64_t MountingTelemetry::getCommitTime() const {
assert(commitStartTime_ != kUndefinedTime);
assert(commitEndTime_ != kUndefinedTime);
return commitEndTime_ - commitStartTime_;
}
int64_t MountingTelemetry::getLayoutTime() const {
assert(layoutStartTime_ != kUndefinedTime);
assert(layoutEndTime_ != kUndefinedTime);
return layoutEndTime_ - layoutEndTime_;
}
int64_t MountingTelemetry::getCommitStartTime() const {
assert(commitStartTime_ != kUndefinedTime);
assert(commitEndTime_ != kUndefinedTime);
return commitStartTime_;
}
} // namespace react
} // namespace facebook