forked from facebookincubator/velox
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Fix merge storageStats_ in IoStatistics (facebookincubator#12263)
Summary: Pull Request resolved: facebookincubator#12263 Differential Revision: D69172665 Pulled By: kewang1024
- Loading branch information
1 parent
ddc20e6
commit bb230e3
Showing
4 changed files
with
88 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Copyright (c) Facebook, Inc. and its affiliates. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
add_executable(velox_ioStatistics_test IoStatisticsTest.cpp) | ||
|
||
add_test(NAME velox_ioStatistics_test COMMAND velox_ioStatistics_test) | ||
|
||
target_link_libraries( | ||
velox_ioStatistics_test | ||
velox_common_base | ||
velox_common_io | ||
GTest::gtest GTest::gtest_main) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
#include "velox/common/io/IoStatistics.h" | ||
#include <gtest/gtest.h> | ||
#include "velox/common/base/RuntimeMetrics.h" | ||
|
||
namespace facebook::velox::io { | ||
|
||
TEST(IoStatisticsTest, merge) { | ||
IoStatistics ioStats; | ||
ioStats.addStorageStats( | ||
"remoteRead", RuntimeCounter(100, RuntimeCounter::Unit::kBytes)); | ||
|
||
IoStatistics ioStats2; | ||
ioStats2.addStorageStats( | ||
"localRead", RuntimeCounter(100, RuntimeCounter::Unit::kBytes)); | ||
ioStats2.addStorageStats( | ||
"remoteRead", RuntimeCounter(200, RuntimeCounter::Unit::kBytes)); | ||
|
||
ioStats.merge(ioStats2); | ||
|
||
RuntimeMetric localReadResult; | ||
localReadResult.unit = RuntimeCounter::Unit::kBytes; | ||
localReadResult.sum = 100; | ||
localReadResult.count = 1; | ||
localReadResult.min = 100; | ||
localReadResult.max = 100; | ||
|
||
RuntimeMetric remoteReadResult; | ||
remoteReadResult.unit = RuntimeCounter::Unit::kBytes; | ||
remoteReadResult.sum = 300; | ||
remoteReadResult.count = 2; | ||
remoteReadResult.min = 100; | ||
remoteReadResult.max = 200; | ||
|
||
EXPECT_EQ( | ||
ioStats.storageStats().at("localRead").toString(), | ||
localReadResult.toString()); | ||
EXPECT_EQ( | ||
ioStats.storageStats().at("remoteRead").toString(), | ||
remoteReadResult.toString()); | ||
} | ||
} // namespace facebook::velox::io |