Merge lp:~albaguirre/ubuntu-performance-tests/use-lttng-tracepoints-mir-app into lp:ubuntu-performance-tests
- use-lttng-tracepoints-mir-app
- Merge into trunk
Proposed by
Alberto Aguirre
Status: | Merged |
---|---|
Merged at revision: | 44 |
Proposed branch: | lp:~albaguirre/ubuntu-performance-tests/use-lttng-tracepoints-mir-app |
Merge into: | lp:ubuntu-performance-tests |
Diff against target: |
469 lines (+254/-80) 9 files modified
utils/apps/src/simple-mir-app/CMakeLists.txt (+7/-2) utils/apps/src/simple-mir-app/cmake/UseLttngGenTp.cmake (+24/-0) utils/apps/src/simple-mir-app/debian/control (+1/-0) utils/apps/src/simple-mir-app/simple-mir-app.desktop (+7/-0) utils/apps/src/simple-mir-app/src/CMakeLists.txt (+10/-1) utils/apps/src/simple-mir-app/src/application.cpp (+69/-0) utils/apps/src/simple-mir-app/src/application.h (+43/-0) utils/apps/src/simple-mir-app/src/simple.cpp (+88/-77) utils/apps/src/simple-mir-app/src/tracepoints.tp (+5/-0) |
To merge this branch: | bzr merge lp:~albaguirre/ubuntu-performance-tests/use-lttng-tracepoints-mir-app |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Sergio Cazzolato | Pending | ||
Review via email: mp+298873@code.launchpad.net |
Commit message
Add lttng tracepoints and make surface orange.
Description of the change
To post a comment you must log in.
- 44. By Alberto Aguirre
-
Add desktop file
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'utils/apps/src/simple-mir-app/CMakeLists.txt' |
2 | --- utils/apps/src/simple-mir-app/CMakeLists.txt 2016-06-02 18:02:55 +0000 |
3 | +++ utils/apps/src/simple-mir-app/CMakeLists.txt 2016-07-01 18:08:13 +0000 |
4 | @@ -18,11 +18,16 @@ |
5 | cmake_minimum_required(VERSION 3.0) |
6 | |
7 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) |
8 | -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -g -Werror -Wall -pedantic -Wextra -fPIC") |
9 | -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -g -std=c++14 -Werror -Wall -fno-strict-aliasing -pedantic -Wnon-virtual-dtor -Wextra -fPIC") |
10 | +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -Werror -Wall -Wextra -std=c11") |
11 | +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -g -std=c++14 -Werror -Wall -pedantic -Wnon-virtual-dtor -Wextra") |
12 | + |
13 | +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) |
14 | +#Needed for generated files from lttng-gen-tp |
15 | +set(CMAKE_INCLUDE_CURRENT_DIR ON) |
16 | |
17 | include(FindPkgConfig) |
18 | #find_package(EGL REQUIRED) |
19 | pkg_check_modules(MIRCLIENT mirclient REQUIRED) |
20 | pkg_check_modules(PLATFORM_API ubuntu-platform-api REQUIRED) |
21 | +pkg_check_modules(LTTNG lttng-ust) |
22 | add_subdirectory(src/) |
23 | |
24 | === added directory 'utils/apps/src/simple-mir-app/cmake' |
25 | === added file 'utils/apps/src/simple-mir-app/cmake/UseLttngGenTp.cmake' |
26 | --- utils/apps/src/simple-mir-app/cmake/UseLttngGenTp.cmake 1970-01-01 00:00:00 +0000 |
27 | +++ utils/apps/src/simple-mir-app/cmake/UseLttngGenTp.cmake 2016-07-01 18:08:13 +0000 |
28 | @@ -0,0 +1,24 @@ |
29 | +cmake_minimum_required(VERSION 2.6) |
30 | +if(POLICY CMP0011) |
31 | + cmake_policy(SET CMP0011 NEW) |
32 | +endif(POLICY CMP0011) |
33 | + |
34 | +find_program(LTTNG_GEN_TP NAMES lttng-gen-tp DOC "lttng-gen-tp executable") |
35 | +if(NOT LTTNG_GEN_TP) |
36 | + message(FATAL_ERROR "Excutable lttng-gen-top not found") |
37 | +endif() |
38 | + |
39 | +function(add_lttng_gen_tp) |
40 | + set(_one_value NAME) |
41 | + cmake_parse_arguments (arg "" "${_one_value}" "" ${ARGN}) |
42 | + |
43 | + add_custom_command( |
44 | + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${arg_NAME}.h" "${CMAKE_CURRENT_BINARY_DIR}/${arg_NAME}.c" |
45 | + COMMAND "${LTTNG_GEN_TP}" |
46 | + -o "${arg_NAME}.h" |
47 | + -o "${arg_NAME}.c" |
48 | + "${CMAKE_CURRENT_SOURCE_DIR}/${arg_NAME}.tp" |
49 | + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} |
50 | + DEPENDS "${arg_NAME}.tp" |
51 | + ) |
52 | +endfunction(add_lttng_gen_tp) |
53 | \ No newline at end of file |
54 | |
55 | === modified file 'utils/apps/src/simple-mir-app/debian/control' |
56 | --- utils/apps/src/simple-mir-app/debian/control 2016-06-02 18:02:55 +0000 |
57 | +++ utils/apps/src/simple-mir-app/debian/control 2016-07-01 18:08:13 +0000 |
58 | @@ -7,6 +7,7 @@ |
59 | pkg-config, |
60 | libmirclient-dev, |
61 | libubuntu-application-api-dev, |
62 | + liblttng-ust-dev, |
63 | Standards-Version: 3.9.4 |
64 | Homepage: https://launchpad.net/ubuntu-performance-tests |
65 | Vcs-Bzr: lp:ubuntu-performance-tests |
66 | |
67 | === added file 'utils/apps/src/simple-mir-app/simple-mir-app.desktop' |
68 | --- utils/apps/src/simple-mir-app/simple-mir-app.desktop 1970-01-01 00:00:00 +0000 |
69 | +++ utils/apps/src/simple-mir-app/simple-mir-app.desktop 2016-07-01 18:08:13 +0000 |
70 | @@ -0,0 +1,7 @@ |
71 | +[Desktop Entry] |
72 | +Type=Application |
73 | +Name=Simple Mir App |
74 | +Exec=/home/phablet/simple-mir-app |
75 | +Icon= |
76 | +Categories=Utility |
77 | +X-Ubuntu-Touch=true |
78 | |
79 | === modified file 'utils/apps/src/simple-mir-app/src/CMakeLists.txt' |
80 | --- utils/apps/src/simple-mir-app/src/CMakeLists.txt 2016-06-02 18:02:55 +0000 |
81 | +++ utils/apps/src/simple-mir-app/src/CMakeLists.txt 2016-07-01 18:08:13 +0000 |
82 | @@ -1,18 +1,27 @@ |
83 | include_directories( |
84 | ${MIRCLIENT_INCLUDE_DIRS} |
85 | ${PLATFORM_API_INCLUDE_DIRS} |
86 | + ${LTTNG_INCLUDE_DIRS} |
87 | ) |
88 | |
89 | -add_executable(simple-mir-app simple.cpp) |
90 | +add_executable(simple-mir-app |
91 | + simple.cpp |
92 | + application.cpp |
93 | + tracepoints.c |
94 | +) |
95 | |
96 | target_link_libraries( |
97 | simple-mir-app |
98 | |
99 | ${MIRCLIENT_LDFLAGS} |
100 | ${PLATFORM_API_LDFLAGS} |
101 | + ${LTTNG_LIBRARIES} |
102 | ) |
103 | |
104 | install(TARGETS |
105 | simple-mir-app |
106 | DESTINATION bin |
107 | ) |
108 | + |
109 | +include(UseLttngGenTp) |
110 | +add_lttng_gen_tp(NAME tracepoints) |
111 | |
112 | === added file 'utils/apps/src/simple-mir-app/src/application.cpp' |
113 | --- utils/apps/src/simple-mir-app/src/application.cpp 1970-01-01 00:00:00 +0000 |
114 | +++ utils/apps/src/simple-mir-app/src/application.cpp 2016-07-01 18:08:13 +0000 |
115 | @@ -0,0 +1,69 @@ |
116 | +/* |
117 | + * Copyright © 2016 Canonical Ltd. |
118 | + * |
119 | + * This program is free software: you can redistribute it and/or modify |
120 | + * it under the terms of the GNU General Public License version 3 as |
121 | + * published by the Free Software Foundation. |
122 | + * |
123 | + * This program is distributed in the hope that it will be useful, |
124 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
125 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
126 | + * GNU General Public License for more details. |
127 | + * |
128 | + * You should have received a copy of the GNU General Public License |
129 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
130 | + * |
131 | + */ |
132 | + |
133 | +#include "application.h" |
134 | + |
135 | +#include <ubuntu/application/id.h> |
136 | + |
137 | +#include <iostream> |
138 | +#include <stdexcept> |
139 | +#include <string> |
140 | + |
141 | +ubuntu::perftest::Application::Application(int argc, char *argv[]) : |
142 | + delegate{u_application_lifecycle_delegate_new()} |
143 | +{ |
144 | + u_application_lifecycle_delegate_set_application_resumed_cb(delegate, &Application::resume); |
145 | + u_application_lifecycle_delegate_set_application_about_to_stop_cb(delegate, &Application::stop); |
146 | + u_application_lifecycle_delegate_set_context(delegate, this); |
147 | + |
148 | + std::string name{"Simple Native App"}; |
149 | + auto id = u_application_id_new_from_stringn(name.c_str(), name.length()); |
150 | + auto description = u_application_description_new(); |
151 | + u_application_description_set_application_id(description, id); |
152 | + u_application_description_set_application_lifecycle_delegate(description, delegate); |
153 | + |
154 | + auto options = u_application_options_new_from_cmd_line(argc, argv); |
155 | + instance = u_application_instance_new_from_description_with_options(description, options); |
156 | + |
157 | + u_application_options_destroy(options); |
158 | + u_application_description_destroy(description); |
159 | + |
160 | + if (instance == nullptr) |
161 | + throw std::runtime_error("Could not create ubuntu app instance!"); |
162 | +} |
163 | + |
164 | +ubuntu::perftest::Application::~Application() |
165 | +{ |
166 | + //FIXME: The symbol below is not exposed in papi library |
167 | + //u_application_instance_unref(instance); |
168 | + u_application_lifecycle_delegate_unref(delegate); |
169 | +} |
170 | + |
171 | +MirConnection* ubuntu::perftest::Application::mir_connection() |
172 | +{ |
173 | + return u_application_instance_get_mir_connection(instance); |
174 | +} |
175 | + |
176 | +void ubuntu::perftest::Application::resume(UApplicationOptions const*, void*) |
177 | +{ |
178 | + std::cout << "Resuming" << std::endl; |
179 | +} |
180 | + |
181 | +void ubuntu::perftest::Application::stop(UApplicationArchive*, void*) |
182 | +{ |
183 | + std::cout << "Stopping" << std::endl; |
184 | +} |
185 | |
186 | === added file 'utils/apps/src/simple-mir-app/src/application.h' |
187 | --- utils/apps/src/simple-mir-app/src/application.h 1970-01-01 00:00:00 +0000 |
188 | +++ utils/apps/src/simple-mir-app/src/application.h 2016-07-01 18:08:13 +0000 |
189 | @@ -0,0 +1,43 @@ |
190 | +/* |
191 | + * Copyright © 2016 Canonical Ltd. |
192 | + * |
193 | + * This program is free software: you can redistribute it and/or modify |
194 | + * it under the terms of the GNU General Public License version 3 as |
195 | + * published by the Free Software Foundation. |
196 | + * |
197 | + * This program is distributed in the hope that it will be useful, |
198 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
199 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
200 | + * GNU General Public License for more details. |
201 | + * |
202 | + * You should have received a copy of the GNU General Public License |
203 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. |
204 | + * |
205 | + */ |
206 | + |
207 | +#include <ubuntu/application/description.h> |
208 | +#include <ubuntu/application/options.h> |
209 | +#include <ubuntu/application/lifecycle_delegate.h> |
210 | +#include <ubuntu/application/instance.h> |
211 | + |
212 | +namespace ubuntu |
213 | +{ |
214 | +namespace perftest |
215 | +{ |
216 | +class Application |
217 | +{ |
218 | +public: |
219 | + Application(int argc, char *argv[]); |
220 | + ~Application(); |
221 | + |
222 | + MirConnection* mir_connection(); |
223 | + |
224 | +private: |
225 | + UApplicationLifecycleDelegate* delegate; |
226 | + UApplicationInstance* instance; |
227 | + |
228 | + static void resume(UApplicationOptions const*, void*); |
229 | + static void stop(UApplicationArchive*, void*); |
230 | +}; |
231 | +} |
232 | +} |
233 | |
234 | === modified file 'utils/apps/src/simple-mir-app/src/simple.cpp' |
235 | --- utils/apps/src/simple-mir-app/src/simple.cpp 2016-06-02 18:02:55 +0000 |
236 | +++ utils/apps/src/simple-mir-app/src/simple.cpp 2016-07-01 18:08:13 +0000 |
237 | @@ -15,6 +15,9 @@ |
238 | * |
239 | */ |
240 | |
241 | +#include "application.h" |
242 | +#include "tracepoints.h" |
243 | + |
244 | #include <ubuntu/application/id.h> |
245 | #include <ubuntu/application/description.h> |
246 | #include <ubuntu/application/options.h> |
247 | @@ -23,12 +26,17 @@ |
248 | |
249 | #include <memory> |
250 | #include <iostream> |
251 | - |
252 | #include <stdexcept> |
253 | |
254 | +#include <signal.h> |
255 | + |
256 | namespace |
257 | { |
258 | |
259 | +using MirSurfaceSpecUp = std::unique_ptr<MirSurfaceSpec, void(*)(MirSurfaceSpec *)>; |
260 | +using MirDisplayConfigUp = std::unique_ptr<MirDisplayConfiguration, void(*)(MirDisplayConfiguration *)>; |
261 | +using MirSurfaceUp = std::unique_ptr<MirSurface, void(*)(MirSurface*)>; |
262 | + |
263 | MirPixelFormat find_default_pixel_format(MirConnection* connection) |
264 | { |
265 | MirPixelFormat pixel_format = mir_pixel_format_invalid; |
266 | @@ -41,6 +49,20 @@ |
267 | return pixel_format; |
268 | } |
269 | |
270 | +auto find_active_mode(MirConnection* connection) |
271 | +{ |
272 | + MirDisplayConfigUp display_config{mir_connection_create_display_config(connection), mir_display_config_destroy}; |
273 | + auto conf = display_config.get(); |
274 | + for (decltype(conf->num_outputs) d = 0; d < conf->num_outputs; d++) |
275 | + { |
276 | + auto out = conf->outputs + d; |
277 | + if (out->used && out->connected && out->num_modes && out->current_mode < out->num_modes) |
278 | + return out->modes[out->current_mode]; |
279 | + } |
280 | + |
281 | + throw std::runtime_error("No active outputs found"); |
282 | +} |
283 | + |
284 | class NormalSpec |
285 | { |
286 | public: |
287 | @@ -52,13 +74,14 @@ |
288 | operator MirSurfaceSpec*() { return spec.get(); } |
289 | |
290 | private: |
291 | - std::unique_ptr<MirSurfaceSpec, void(*)(MirSurfaceSpec *)> spec; |
292 | + MirSurfaceSpecUp spec; |
293 | }; |
294 | |
295 | MirSurface* make_surface(MirConnection* connection) |
296 | { |
297 | auto pixel_format = find_default_pixel_format(connection); |
298 | - NormalSpec spec(connection, 640, 480, pixel_format); |
299 | + auto mode = find_active_mode(connection); |
300 | + NormalSpec spec(connection, mode.horizontal_resolution, mode.vertical_resolution, pixel_format); |
301 | return mir_surface_create_sync(spec); |
302 | } |
303 | |
304 | @@ -74,93 +97,81 @@ |
305 | } |
306 | } |
307 | |
308 | + void draw() |
309 | + { |
310 | + auto stream = get_stream(); |
311 | + |
312 | + MirGraphicsRegion region; |
313 | + mir_buffer_stream_get_graphics_region(stream, ®ion); |
314 | + |
315 | + uint32_t const color = 0xFF2448DD; //orange |
316 | + uint8_t* line_addr = reinterpret_cast<uint8_t*>(region.vaddr); |
317 | + for (int y = 0; y < region.height; y++) |
318 | + { |
319 | + uint32_t* pixel_addr = reinterpret_cast<uint32_t*>(line_addr); |
320 | + line_addr += region.stride; |
321 | + for (int x = 0; x < region.width; x++) |
322 | + { |
323 | + *pixel_addr = color; |
324 | + pixel_addr++; |
325 | + } |
326 | + } |
327 | + } |
328 | + |
329 | void swap_buffers() |
330 | { |
331 | + auto stream = get_stream(); |
332 | + mir_buffer_stream_swap_buffers_sync(stream); |
333 | + } |
334 | + |
335 | +private: |
336 | + MirBufferStream* get_stream() |
337 | + { |
338 | auto stream = mir_surface_get_buffer_stream(surface.get()); |
339 | if (!mir_buffer_stream_is_valid(stream)) |
340 | { |
341 | throw std::runtime_error(mir_buffer_stream_get_error_message(stream)); |
342 | } |
343 | - mir_buffer_stream_swap_buffers_sync(stream); |
344 | - } |
345 | - |
346 | -private: |
347 | - std::unique_ptr<MirSurface, void(*)(MirSurface*)> surface; |
348 | -}; |
349 | - |
350 | -class Application |
351 | -{ |
352 | -public: |
353 | - Application(int argc, char *argv[]) : |
354 | - delegate{u_application_lifecycle_delegate_new()} |
355 | - { |
356 | - u_application_lifecycle_delegate_set_application_resumed_cb(delegate, &Application::resume); |
357 | - u_application_lifecycle_delegate_set_application_about_to_stop_cb(delegate, &Application::stop); |
358 | - u_application_lifecycle_delegate_set_context(delegate, this); |
359 | - |
360 | - std::string name{"Simple Native App"}; |
361 | - auto id = u_application_id_new_from_stringn(name.c_str(), name.length()); |
362 | - auto description = u_application_description_new(); |
363 | - u_application_description_set_application_id(description, id); |
364 | - u_application_description_set_application_lifecycle_delegate(description, delegate); |
365 | - |
366 | - auto options = u_application_options_new_from_cmd_line(argc, argv); |
367 | - instance = u_application_instance_new_from_description_with_options(description, options); |
368 | - |
369 | - u_application_options_destroy(options); |
370 | - u_application_description_destroy(description); |
371 | - |
372 | - if (instance == nullptr) |
373 | - throw std::runtime_error("Could not create ubuntu app instance!"); |
374 | - } |
375 | - |
376 | - ~Application() |
377 | - { |
378 | - //FIXME: The symbol below is not exposed in papi library |
379 | - //u_application_instance_unref(instance); |
380 | - u_application_lifecycle_delegate_unref(delegate); |
381 | - } |
382 | - |
383 | - auto make_surface() |
384 | - { |
385 | - auto connection = u_application_instance_get_mir_connection(instance); |
386 | - return std::make_unique<Surface>(connection); |
387 | - } |
388 | - |
389 | - static void resume(UApplicationOptions const*, void*) |
390 | - { |
391 | - std::cout << "Resuming" << std::endl; |
392 | - } |
393 | - |
394 | - static void stop(UApplicationArchive*, void*) |
395 | - { |
396 | - std::cout << "Stopping" << std::endl; |
397 | - } |
398 | - |
399 | -private: |
400 | - UApplicationLifecycleDelegate* delegate; |
401 | - UApplicationInstance* instance; |
402 | -}; |
403 | - |
404 | -void print_current_time(void) |
405 | -{ |
406 | - struct timespec spec; |
407 | - clock_gettime(CLOCK_REALTIME, &spec); |
408 | - std::cout << "time after swap(sec:nanosec) - " << spec.tv_sec; |
409 | - std::cout << ":" << spec.tv_nsec << std::endl; |
410 | + return stream; |
411 | + } |
412 | + MirSurfaceUp surface; |
413 | +}; |
414 | + |
415 | +void wait_for_signal() |
416 | +{ |
417 | + sigset_t sigs; |
418 | + sigemptyset(&sigs); |
419 | + |
420 | + sigaddset(&sigs, SIGINT); |
421 | + sigaddset(&sigs, SIGTERM); |
422 | + sigaddset(&sigs, SIGHUP); |
423 | + |
424 | + sigprocmask(SIG_BLOCK, &sigs, nullptr); |
425 | + |
426 | + int signum; |
427 | + sigwait(&sigs, &signum); |
428 | + std::cout << "Signal " << signum << " received. Exiting." << std::endl; |
429 | } |
430 | } |
431 | |
432 | int main(int argc, char *argv[]) |
433 | try |
434 | { |
435 | - Application app(argc, argv); |
436 | - |
437 | - auto surface = app.make_surface(); |
438 | - surface->swap_buffers(); |
439 | - |
440 | - print_current_time(); |
441 | - std::cout << "Done." << std::endl; |
442 | + tracepoint(mirApp, start); |
443 | + ubuntu::perftest::Application app(argc, argv); |
444 | + tracepoint(mirApp, papiInitialized); |
445 | + |
446 | + Surface surface{app.mir_connection()}; |
447 | + tracepoint(mirApp, surfaceCreated); |
448 | + |
449 | + surface.draw(); |
450 | + tracepoint(mirApp, surfaceDrawn); |
451 | + |
452 | + surface.swap_buffers(); |
453 | + tracepoint(mirApp, surfaceSwapped); |
454 | + |
455 | + wait_for_signal(); |
456 | +; |
457 | } |
458 | catch(std::exception const& e) |
459 | { |
460 | |
461 | === added file 'utils/apps/src/simple-mir-app/src/tracepoints.tp' |
462 | --- utils/apps/src/simple-mir-app/src/tracepoints.tp 1970-01-01 00:00:00 +0000 |
463 | +++ utils/apps/src/simple-mir-app/src/tracepoints.tp 2016-07-01 18:08:13 +0000 |
464 | @@ -0,0 +1,5 @@ |
465 | +TRACEPOINT_EVENT(mirApp, start, TP_ARGS(0), TP_FIELDS()) |
466 | +TRACEPOINT_EVENT(mirApp, papiInitialized, TP_ARGS(0), TP_FIELDS()) |
467 | +TRACEPOINT_EVENT(mirApp, surfaceCreated, TP_ARGS(0), TP_FIELDS()) |
468 | +TRACEPOINT_EVENT(mirApp, surfaceDrawn, TP_ARGS(0), TP_FIELDS()) |
469 | +TRACEPOINT_EVENT(mirApp, surfaceSwapped, TP_ARGS(0), TP_FIELDS()) |