Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(933)

Unified Diff: ios/chrome/test/base/perf_test_ios.h

Issue 2580333003: Upstream Chrome on iOS source code [10/11]. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/chrome/test/app/web_view_interaction_test_util.mm ('k') | ios/chrome/test/base/perf_test_ios.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/chrome/test/base/perf_test_ios.h
diff --git a/ios/chrome/test/base/perf_test_ios.h b/ios/chrome/test/base/perf_test_ios.h
new file mode 100644
index 0000000000000000000000000000000000000000..cdb21535bad4c8396b89408cb801fb3d89a37ce9
--- /dev/null
+++ b/ios/chrome/test/base/perf_test_ios.h
@@ -0,0 +1,78 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef IOS_CHROME_TEST_BASE_PERF_TEST_IOS_H_
+#define IOS_CHROME_TEST_BASE_PERF_TEST_IOS_H_
+
+#import <Foundation/Foundation.h>
+
+#include "base/ios/block_types.h"
+#include "base/time/time.h"
+#import "ios/chrome/test/block_cleanup_test.h"
+#include "ios/web/public/test/scoped_testing_web_client.h"
+#include "ios/web/public/test/test_web_thread_bundle.h"
+
+typedef base::TimeDelta (^TimedActionBlock)(int index);
+
+// Base class for PerfTest providing some common functions that are
+// generally useful.
+class PerfTest : public BlockCleanupTest {
+ public:
+ explicit PerfTest(std::string testGroup);
+ PerfTest(std::string testGroup,
+ std::string firstLabel,
+ std::string averageLabel,
+ bool isWaterfall,
+ bool verbose,
+ int repeat);
+ ~PerfTest() override;
+
+ // Convenience methods to display the performance timing data.
+ // All recorded values will show up on the bot performance graphs. If
+ // |isWaterfall_| is true, the performance data recorded will show up on the
+ // waterfall. In the majority of the cases, |isWaterfall_| should be false.
+ virtual void LogPerfValue(std::string testName,
+ double value,
+ std::string unit);
+ virtual void LogPerfTiming(std::string testName, base::TimeDelta elapsed);
+
+ // Utility method to run a test multiple times.
+ // The first run is counted separately to account for possible lazy
+ // initialization overhead. Subsequent run times are averaged to provide
+ // reliable timings for comparison.
+ virtual void RepeatTimedRuns(std::string testName,
+ TimedActionBlock timedAction,
+ ProceduralBlock postAction);
+ virtual void RepeatTimedRuns(std::string testName,
+ TimedActionBlock timedAction,
+ ProceduralBlock postAction,
+ int repeatCount);
+
+ // Computes the average time, and, optionally, returns the maximum and
+ // minimum times seen.
+ static base::TimeDelta CalculateAverage(base::TimeDelta* times,
+ int count,
+ base::TimeDelta* min_time,
+ base::TimeDelta* max_time);
+
+ private:
+ // Name for this group of perf tests.
+ std::string testGroup_;
+ // The label added to the first test of multiple tests.
+ std::string firstLabel_;
+ // The label added to the average number for multiple tests.
+ std::string averageLabel_;
+ // Whether the test result should appear in the waterfall.
+ bool isWaterfall_;
+ // Flag to show generate more output.
+ bool verbose_;
+ // Sets number of times to repeat a test when ran with RepeatTimedRuns.
+ int repeatCount_;
+ // The threads used for testing.
+ web::TestWebThreadBundle thread_bundle_;
+ // The WebClient for testing purposes.
+ web::ScopedTestingWebClient web_client_;
+};
+
+#endif // IOS_CHROME_TEST_BASE_PERF_TEST_IOS_H_
« no previous file with comments | « ios/chrome/test/app/web_view_interaction_test_util.mm ('k') | ios/chrome/test/base/perf_test_ios.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698