Mir

Merge lp:~albaguirre/mir/simple-startup-perf-test into lp:mir

Proposed by Alberto Aguirre
Status: Merged
Approved by: Daniel van Vugt
Approved revision: no longer in the source branch.
Merged at revision: 3505
Proposed branch: lp:~albaguirre/mir/simple-startup-perf-test
Merge into: lp:mir
Diff against target: 165 lines (+130/-1)
4 files modified
debian/mir-test-tools.install (+1/-0)
tests/performance-tests/CMakeLists.txt (+12/-0)
tests/performance-tests/performance_tests.sh (+2/-1)
tests/performance-tests/test_client_startup.cpp (+115/-0)
To merge this branch: bzr merge lp:~albaguirre/mir/simple-startup-perf-test
Reviewer Review Type Date Requested Status
Daniel van Vugt Approve
Mir CI Bot continuous-integration Approve
Review via email: mp+294315@code.launchpad.net

Commit message

Add a simple client startup performance test

Add test to ensure the required time for a client to setup a connection,
create a surface and swap a buffer does not exceed the expected threshold.

To post a comment you must log in.
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Mir CI Bot (mir-ci-bot) wrote :

PASSED: Continuous integration, rev:3505
https://mir-jenkins.ubuntu.com/job/mir-ci/969/
Executed test runs:
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-mir/1043
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-0-fetch/1090
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=vivid+overlay/1081
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-1-sourcepkg/release=xenial/1081
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/1053
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=clang,platform=mesa,release=vivid+overlay/1053/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/1053
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=amd64,compiler=gcc,platform=mesa,release=xenial/1053/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1053
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=cross-armhf,compiler=gcc,platform=android,release=vivid+overlay/1053/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1053
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=android,release=vivid+overlay/1053/artifact/output/*zip*/output.zip
    SUCCESS: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/1053
        deb: https://mir-jenkins.ubuntu.com/job/build-2-binpkg-mir/arch=i386,compiler=gcc,platform=mesa,release=xenial/1053/artifact/output/*zip*/output.zip

Click here to trigger a rebuild:
https://mir-jenkins.ubuntu.com/job/mir-ci/969/rebuild

review: Approve (continuous-integration)
Revision history for this message
Daniel van Vugt (vanvugt) wrote :

That's a good idea. Don't need to fuss over the code structure...

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/mir-test-tools.install'
2--- debian/mir-test-tools.install 2016-05-06 08:57:57 +0000
3+++ debian/mir-test-tools.install 2016-05-11 03:44:15 +0000
4@@ -7,6 +7,7 @@
5 usr/bin/mir_performance_tests
6 usr/bin/mir_glmark2_performance_test
7 usr/bin/mir_compositor_performance_test
8+usr/bin/mir_client_startup_performance_test
9 usr/bin/mir_privileged_tests
10 usr/bin/mir_test_reload_protobuf
11 usr/bin/mir_test_client_*
12
13=== modified file 'tests/performance-tests/CMakeLists.txt'
14--- tests/performance-tests/CMakeLists.txt 2016-05-06 07:34:57 +0000
15+++ tests/performance-tests/CMakeLists.txt 2016-05-11 03:44:15 +0000
16@@ -23,3 +23,15 @@
17 target_link_libraries(mir_compositor_performance_test
18 ${GTEST_BOTH_LIBRARIES}
19 )
20+
21+mir_add_wrapped_executable(mir_client_startup_performance_test
22+ test_client_startup.cpp
23+)
24+target_link_libraries(mir_client_startup_performance_test
25+ mir-test-static
26+ mir-test-framework-static
27+ mir-test-doubles-static
28+ mirserver
29+ ${GTEST_BOTH_LIBRARIES}
30+)
31+
32
33=== modified file 'tests/performance-tests/performance_tests.sh'
34--- tests/performance-tests/performance_tests.sh 2016-05-06 07:34:57 +0000
35+++ tests/performance-tests/performance_tests.sh 2016-05-11 03:44:15 +0000
36@@ -31,7 +31,8 @@
37 tests_run=0
38 failures=0
39 for perf_test in mir_glmark2_performance_test \
40- mir_compositor_performance_test
41+ mir_compositor_performance_test \
42+ mir_client_startup_performance_test
43 do
44 title_banner "Mir Performance Tests now running: $perf_test"
45 tests_run=$(($tests_run + 1))
46
47=== added file 'tests/performance-tests/test_client_startup.cpp'
48--- tests/performance-tests/test_client_startup.cpp 1970-01-01 00:00:00 +0000
49+++ tests/performance-tests/test_client_startup.cpp 2016-05-11 03:44:15 +0000
50@@ -0,0 +1,115 @@
51+/*
52+ * Copyright © 2016 Canonical Ltd.
53+ *
54+ * This program is free software: you can redistribute it and/or modify it
55+ * under the terms of the GNU General Public License version 3,
56+ * as published by the Free Software Foundation.
57+ *
58+ * This program is distributed in the hope that it will be useful,
59+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
60+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
61+ * GNU General Public License for more details.
62+ *
63+ * You should have received a copy of the GNU General Public License
64+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
65+ */
66+
67+#include "mir_test_framework/async_server_runner.h"
68+#include "mir_toolkit/mir_client_library.h"
69+
70+#include "mir/test/validity_matchers.h"
71+
72+#include <gmock/gmock.h>
73+#include <gtest/gtest.h>
74+
75+#include <chrono>
76+
77+namespace mtf = mir_test_framework;
78+
79+using namespace testing;
80+
81+namespace
82+{
83+struct ClientStartupPerformance : testing::Test, mtf::AsyncServerRunner
84+{
85+ void SetUp() override
86+ {
87+ start_server();
88+ }
89+
90+ void TearDown() override
91+ {
92+ stop_server();
93+ }
94+
95+ MirConnection* create_connection()
96+ {
97+ auto conn = mir_connect_sync(new_connection().c_str(), "Perf test");
98+ if (!mir_connection_is_valid(conn))
99+ {
100+ std::string error_msg{"Could not create connection: "};
101+ error_msg.append(mir_connection_get_error_message(conn));
102+ throw std::runtime_error(error_msg);
103+ }
104+ return conn;
105+ }
106+};
107+
108+MirPixelFormat find_pixel_format(MirConnection* connection)
109+{
110+ MirPixelFormat pixel_format = mir_pixel_format_invalid;
111+ unsigned int valid_formats;
112+ mir_connection_get_available_surface_formats(connection, &pixel_format, 1, &valid_formats);
113+ if (valid_formats < 1 || pixel_format == mir_pixel_format_invalid)
114+ throw std::runtime_error("Could not find pixel format");
115+ return pixel_format;
116+}
117+
118+MirSurface* make_surface(MirConnection* connection)
119+{
120+ auto format = find_pixel_format(connection);
121+
122+ auto spec = mir_connection_create_spec_for_normal_surface(connection,
123+ 720, 1280, format);
124+ auto surface = mir_surface_create_sync(spec);
125+
126+ mir_surface_spec_release(spec);
127+
128+ if (!mir_surface_is_valid(surface))
129+ {
130+ std::string error_msg{"Could not create surface: "};
131+ error_msg.append(mir_surface_get_error_message(surface));
132+ throw std::runtime_error(error_msg);
133+ }
134+ return surface;
135+}
136+}
137+
138+TEST_F(ClientStartupPerformance, create_surface_and_swap)
139+{
140+ using namespace std::chrono_literals;
141+ auto start = std::chrono::steady_clock::now();
142+
143+ auto conn = create_connection();
144+ auto surf = make_surface(conn);
145+ auto stream = mir_surface_get_buffer_stream(surf);
146+ if (!mir_buffer_stream_is_valid(stream))
147+ {
148+ std::string error_msg{"Could not get buffer stream from surface: "};
149+ error_msg.append(mir_buffer_stream_get_error_message(stream));
150+ throw std::runtime_error(error_msg);
151+ }
152+
153+ mir_buffer_stream_swap_buffers_sync(stream);
154+
155+ auto end = std::chrono::steady_clock::now();
156+ auto diff = std::chrono::duration_cast<std::chrono::milliseconds>(end-start);
157+
158+ //NOTE: Ideally, the expected number should vary according to platform
159+ auto max_expected_time = 80ms;
160+ EXPECT_THAT(diff.count(), Lt(max_expected_time.count()));
161+
162+ mir_surface_release_sync(surf);
163+ mir_connection_release(conn);
164+}
165+

Subscribers

People subscribed via source and target branches