| OLD | NEW |
| (Empty) |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <!-- | |
| 4 Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
| 5 Use of this source code is governed by a BSD-style license that can be | |
| 6 found in the LICENSE file. | |
| 7 --> | |
| 8 <head> | |
| 9 <title>LinuxPerfImporter tests</title> | |
| 10 <script src= | |
| 11 "http://closure-library.googlecode.com/svn/trunk/closure/goog/base.js"> | |
| 12 </script> | |
| 13 <script src="../shared/js/cr.js"></script> | |
| 14 <script src="../shared/js/cr/event_target.js"></script> | |
| 15 <script src="test_utils.js"></script> | |
| 16 <script src="timeline_model.js"></script> | |
| 17 <script src="linux_perf_importer.js"></script> | |
| 18 <script> | |
| 19 goog.require('goog.testing.jsunit'); | |
| 20 </script> | |
| 21 | |
| 22 </head> | |
| 23 <body> | |
| 24 <script> | |
| 25 function testLineRE() { | |
| 26 var re = tracing._LinuxPerfImporterTestExports.lineRE; | |
| 27 var x = re.exec(' <idle>-0 [001] 4467.843475: sched_switch: ' + | |
| 28 'prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ==> ' + | |
| 29 'next_comm=SurfaceFlinger next_pid=178 next_prio=112'); | |
| 30 assertNotNull(x); | |
| 31 assertEquals('<idle>-0', x[1]); | |
| 32 assertEquals('001', x[2]); | |
| 33 assertEquals('4467.843475', x[3]); | |
| 34 assertEquals('sched_switch', x[4]); | |
| 35 assertEquals('prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ==> ' + | |
| 36 'next_comm=SurfaceFlinger next_pid=178 next_prio=112', x[5]); | |
| 37 | |
| 38 var x = re.exec('Binder Thread #-647 [001] 260.464294: sched_switch: ' + | |
| 39 'prev_comm=Binder Thread # prev_pid=647 prev_prio=120 prev_state=D ==> ' + | |
| 40 'next_comm=.android.chrome next_pid=1562 next_prio=120'); | |
| 41 assertNotNull(x); | |
| 42 } | |
| 43 | |
| 44 function testSchedSwitchRE() { | |
| 45 var re = tracing._LinuxPerfImporterTestExports.schedSwitchRE; | |
| 46 var x = re.exec('prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ' + | |
| 47 '==> next_comm=SurfaceFlinger next_pid=178 next_prio=112'); | |
| 48 assertNotNull(x); | |
| 49 assertEquals('swapper', x[1]); | |
| 50 assertEquals('0', x[2]); | |
| 51 assertEquals('120', x[3]); | |
| 52 assertEquals('R', x[4]); | |
| 53 assertEquals('SurfaceFlinger', x[5]); | |
| 54 assertEquals('178', x[6]); | |
| 55 assertEquals('112', x[7]); | |
| 56 | |
| 57 var x = re.exec('prev_comm=.android.chrome prev_pid=1562 prev_prio=120 ' + | |
| 58 'prev_state=R ==> next_comm=Binder Thread # next_pid=195 next_prio=120'); | |
| 59 assertNotNull(x); | |
| 60 assertEquals('.android.chrome', x[1]); | |
| 61 assertEquals('Binder Thread #', x[5]); | |
| 62 | |
| 63 var x = re.exec('prev_comm=Binder Thread # prev_pid=1562 prev_prio=120 ' + | |
| 64 'prev_state=R ==> next_comm=.android.chrome next_pid=195 next_prio=120'); | |
| 65 assertNotNull(x); | |
| 66 assertEquals('Binder Thread #', x[1]); | |
| 67 assertEquals('.android.chrome', x[5]); | |
| 68 } | |
| 69 | |
| 70 function testSchedWakeupRE() { | |
| 71 var re = tracing._LinuxPerfImporterTestExports.schedWakeupRE; | |
| 72 var x = re.exec( | |
| 73 'comm=SensorService pid=207 prio=112 success=1 target_cpu=000'); | |
| 74 assertNotNull(x); | |
| 75 assertEquals('SensorService', x[1]); | |
| 76 assertEquals('207', x[2]); | |
| 77 assertEquals('112', x[3]); | |
| 78 assertEquals('1', x[4]); | |
| 79 assertEquals('000', x[5]); | |
| 80 } | |
| 81 | |
| 82 function testTraceEventClockSyncRE() { | |
| 83 var re = tracing._LinuxPerfImporterTestExports.traceEventClockSyncRE; | |
| 84 var x = re.exec('trace_event_clock_sync: parent_ts=19581477508'); | |
| 85 assertNotNull(x); | |
| 86 assertEquals('19581477508', x[1]); | |
| 87 | |
| 88 var x = re.exec('trace_event_clock_sync: parent_ts=123.456'); | |
| 89 assertNotNull(x); | |
| 90 assertEquals('123.456', x[1]); | |
| 91 } | |
| 92 | |
| 93 function testCanImport() { | |
| 94 var lines = [ | |
| 95 '# tracer: nop', | |
| 96 '#', | |
| 97 '# TASK-PID CPU# TIMESTAMP FUNCTION', | |
| 98 '# | | | | |', | |
| 99 ' <idle>-0 [001] 4467.843475: sched_switch: ' + | |
| 100 'prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ==> ' + | |
| 101 'next_comm=SurfaceFlinger next_pid=178 next_prio=112', | |
| 102 | |
| 103 ' SurfaceFlinger-178 [001] 4467.843536: sched_switch: ' + | |
| 104 'prev_comm=SurfaceFlinger prev_pid=178 prev_prio=112 prev_state=S ' + | |
| 105 '==> next_comm=kworker/u:2 next_pid=2844 next_prio=120', | |
| 106 | |
| 107 ' kworker/u:2-2844 [001] 4467.843567: sched_switch: ' + | |
| 108 'prev_comm=kworker/u:2 prev_pid=2844 prev_prio=120 prev_state=S ' + | |
| 109 '==> next_comm=swapper next_pid=0 next_prio=120', | |
| 110 | |
| 111 ' <idle>-0 [001] 4467.844208: sched_switch: ' + | |
| 112 'prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ==> ' + | |
| 113 'next_comm=kworker/u:2 next_pid=2844 next_prio=120' | |
| 114 ]; | |
| 115 assertTrue(tracing.LinuxPerfImporter.canImport(lines.join('\n'))); | |
| 116 | |
| 117 var lines = [ | |
| 118 ' <idle>-0 [001] 4467.843475: sched_switch: ' + | |
| 119 'prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ==> ' + | |
| 120 'next_comm=SurfaceFlinger next_pid=178 next_prio=112' | |
| 121 ]; | |
| 122 assertTrue(tracing.LinuxPerfImporter.canImport(lines.join('\n'))); | |
| 123 | |
| 124 var lines = [ | |
| 125 ' <idle>-0 [001] 4467.843475: sched_switch: ' + | |
| 126 'prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ==> ' + | |
| 127 'next_comm=SurfaceFlinger next_pid=178 next_prio=112', | |
| 128 | |
| 129 ' SurfaceFlinger-178 [001] 4467.843536: sched_switch: ' + | |
| 130 'prev_comm=SurfaceFlinger prev_pid=178 prev_prio=112 ' + | |
| 131 'prev_state=S ==> next_comm=kworker/u:2 next_pid=2844 ' + | |
| 132 'next_prio=120' | |
| 133 ]; | |
| 134 assertTrue(tracing.LinuxPerfImporter.canImport(lines.join('\n'))); | |
| 135 | |
| 136 var lines = [ | |
| 137 'SomeRandomText', | |
| 138 'More random text' | |
| 139 ]; | |
| 140 assertFalse(tracing.LinuxPerfImporter.canImport(lines.join('\n'))); | |
| 141 } | |
| 142 | |
| 143 function testImportOneSequence() { | |
| 144 var lines = [ | |
| 145 ' <idle>-0 [001] 4467.843475: sched_switch: ' + | |
| 146 'prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ==> ' + | |
| 147 'next_comm=SurfaceFlinger next_pid=178 next_prio=112', | |
| 148 | |
| 149 ' SurfaceFlinger-178 [001] 4467.843536: sched_switch: ' + | |
| 150 'prev_comm=SurfaceFlinger prev_pid=178 prev_prio=112 ' + | |
| 151 'prev_state=S ==> next_comm=kworker/u:2 next_pid=2844 ' + | |
| 152 'next_prio=120', | |
| 153 | |
| 154 ' kworker/u:2-2844 [001] 4467.843567: sched_switch: ' + | |
| 155 'prev_comm=kworker/u:2 prev_pid=2844 prev_prio=120 ' + | |
| 156 'prev_state=S ==> next_comm=swapper next_pid=0 next_prio=120' | |
| 157 ]; | |
| 158 var m = new tracing.TimelineModel(lines.join('\n'), false); | |
| 159 assertEquals(0, m.importErrors.length); | |
| 160 | |
| 161 var c = m.cpus[1]; | |
| 162 assertEquals(2, c.slices.length); | |
| 163 | |
| 164 assertEquals('SurfaceFlinger', c.slices[0].title); | |
| 165 assertEquals(4467843.475, c.slices[0].start); | |
| 166 assertAlmostEquals(.536 - .475, c.slices[0].duration); | |
| 167 } | |
| 168 | |
| 169 function testImportOneSequenceWithSchedWakeUp() { | |
| 170 // TODO(nduca): write test for this. | |
| 171 } | |
| 172 | |
| 173 function testImportWithNewline() { | |
| 174 var lines = [ | |
| 175 '' | |
| 176 ]; | |
| 177 var m = new tracing.TimelineModel(lines.join('\n')); | |
| 178 assertEquals(0, m.importErrors.length); | |
| 179 } | |
| 180 | |
| 181 function testClockSync() { | |
| 182 var lines = [ | |
| 183 ' <idle>-0 [001] 4467.843475: sched_switch: ' + | |
| 184 'prev_comm=swapper prev_pid=0 prev_prio=120 prev_state=R ' + | |
| 185 '==> next_comm=SurfaceFlinger next_pid=178 next_prio=112', | |
| 186 ' SurfaceFlinger-178 [001] 4467.843536: sched_switch: ' + | |
| 187 'prev_comm=SurfaceFlinger prev_pid=178 prev_prio=112 ' + | |
| 188 'prev_state=S ==> next_comm=kworker/u:2 next_pid=2844 ' + | |
| 189 'next_prio=120', | |
| 190 ' kworker/u:2-2844 [001] 4467.843567: sched_switch: ' + | |
| 191 'prev_comm=kworker/u:2 prev_pid=2844 prev_prio=120 ' + | |
| 192 'prev_state=S ==> next_comm=swapper next_pid=0 ' + | |
| 193 'next_prio=120', | |
| 194 ' kworker/u:2-2844 [001] 4467.843000: 0: ' + | |
| 195 'trace_event_clock_sync: parent_ts=0.1' | |
| 196 ]; | |
| 197 var m = new tracing.TimelineModel(lines.join('\n'), false); | |
| 198 assertEquals(0, m.importErrors.length); | |
| 199 | |
| 200 var c = m.cpus[1]; | |
| 201 assertEquals(2, c.slices.length); | |
| 202 | |
| 203 assertAlmostEquals((467.843475 - (467.843 - 0.1)) * 1000, c.slices[0].start); | |
| 204 } | |
| 205 | |
| 206 function testClockSyncMarkWrite() { | |
| 207 var lines = [ | |
| 208 'systrace.sh-8170 [001] 15180.978813: sched_switch: ' + | |
| 209 'prev_comm=systrace.sh prev_pid=8170 prev_prio=120 ' + | |
| 210 'prev_state=x ==> next_comm=kworker/1:0 next_pid=7873 ' + | |
| 211 'next_prio=120', | |
| 212 ' kworker/1:0-7873 [001] 15180.978836: sched_switch: ' + | |
| 213 'prev_comm=kworker/1:0 prev_pid=7873 prev_prio=120 ' + | |
| 214 'prev_state=S ==> next_comm=debugd next_pid=4404 next_prio=120', | |
| 215 ' debugd-4404 [001] 15180.979010: sched_switch: prev_comm=debugd ' + | |
| 216 'prev_pid=4404 prev_prio=120 prev_state=S ==> ' + | |
| 217 'next_comm=dbus-daemon next_pid=510 next_prio=120', | |
| 218 'systrace.sh-8182 [000] 15186.203900: tracing_mark_write: ' + | |
| 219 'trace_event_clock_sync: parent_ts=0' | |
| 220 ]; | |
| 221 var m = new tracing.TimelineModel(lines.join('\n'), false); | |
| 222 assertEquals(0, m.importErrors.length); | |
| 223 | |
| 224 var c = m.cpus[1]; | |
| 225 assertEquals(2, c.slices.length); | |
| 226 | |
| 227 assertAlmostEquals((15180.978813 - 0) * 1000, c.slices[0].start); | |
| 228 } | |
| 229 | |
| 230 | |
| 231 function testImportWithoutClockSyncDeletesEverything() { | |
| 232 } | |
| 233 | |
| 234 function testWorkQueueImport() { | |
| 235 var lines = [ | |
| 236 ' kworker/0:3-6880 [000] 2784.771958: workqueue_execute_start: ' + | |
| 237 'work struct ffff8800a5083a20: function intel_unpin_work_fn', | |
| 238 ' kworker/0:3-6880 [000] 2784.771966: workqueue_execute_end: ' + | |
| 239 'work struct ffff8800a5083a20', | |
| 240 ' kworker/1:2-7269 [001] 2784.805966: workqueue_execute_start: ' + | |
| 241 'work struct ffff88014fb0f158: function do_dbs_timer', | |
| 242 ' kworker/1:2-7269 [001] 2784.805975: workqueue_execute_end: ' + | |
| 243 'work struct ffff88014fb0f158' | |
| 244 ]; | |
| 245 var m = new tracing.TimelineModel(lines.join('\n'), false); | |
| 246 assertEquals(0, m.importErrors.length); | |
| 247 | |
| 248 assertEquals(1, m.processes['6880'].threads['6880'].subRows.length); | |
| 249 assertEquals(1, m.processes['7269'].threads['7269'].subRows.length); | |
| 250 } | |
| 251 | |
| 252 function testPowerStartImport() { | |
| 253 } | |
| 254 | |
| 255 function testPowerFrequencyImport() { | |
| 256 var lines = [ | |
| 257 ' kworker/0:3-6880 [000] 2784.783015: power_frequency: ' + | |
| 258 'type=2 state=1000000 cpu_id=0', | |
| 259 ' kworker/1:2-7269 [001] 2784.788993: power_frequency: ' + | |
| 260 'type=2 state=800000 cpu_id=1', | |
| 261 ' kworker/1:2-7269 [001] 2784.993120: power_frequency: ' + | |
| 262 'type=2 state=1300000 cpu_id=1' | |
| 263 ]; | |
| 264 var m = new tracing.TimelineModel(lines.join('\n'), false); | |
| 265 assertEquals(0, m.importErrors.length); | |
| 266 | |
| 267 var c0 = m.cpus[0]; | |
| 268 assertEquals(0, c0.slices.length); | |
| 269 assertEquals(1, c0.counters['Clock Frequency'].samples.length); | |
| 270 | |
| 271 var c1 = m.cpus[1]; | |
| 272 assertEquals(0, c1.slices.length); | |
| 273 assertEquals(2, c1.counters['Clock Frequency'].samples.length); | |
| 274 } | |
| 275 | |
| 276 function testCpuFrequencyImport() { | |
| 277 var lines = [ | |
| 278 ' kworker/1:0-9665 [001] 15051.007301: cpu_frequency: ' + | |
| 279 'state=800000 cpu_id=1', | |
| 280 ' kworker/1:0-9665 [001] 15051.010278: cpu_frequency: ' + | |
| 281 'state=1300000 cpu_id=1', | |
| 282 ' kworker/0:2-7972 [000] 15051.010278: cpu_frequency: ' + | |
| 283 'state=1000000 cpu_id=0', | |
| 284 ' kworker/0:2-7972 [000] 15051.020304: cpu_frequency: ' + | |
| 285 'state=800000 cpu_id=0' | |
| 286 ]; | |
| 287 var m = new tracing.TimelineModel(lines.join('\n'), false); | |
| 288 assertEquals(0, m.importErrors.length); | |
| 289 | |
| 290 var c0 = m.cpus[0]; | |
| 291 assertEquals(0, c0.slices.length); | |
| 292 assertEquals(2, c0.counters['Clock Frequency'].samples.length); | |
| 293 | |
| 294 var c1 = m.cpus[1]; | |
| 295 assertEquals(0, c1.slices.length); | |
| 296 assertEquals(2, c1.counters['Clock Frequency'].samples.length); | |
| 297 } | |
| 298 | |
| 299 function testCpuIdleImport() { | |
| 300 var lines = [ | |
| 301 ' <idle>-0 [000] 15050.992883: cpu_idle: ' + | |
| 302 'state=1 cpu_id=0', | |
| 303 ' <idle>-0 [000] 15050.993027: cpu_idle: ' + | |
| 304 'state=4294967295 cpu_id=0', | |
| 305 ' <idle>-0 [001] 15050.993132: cpu_idle: ' + | |
| 306 'state=1 cpu_id=1', | |
| 307 ' <idle>-0 [001] 15050.993276: cpu_idle: ' + | |
| 308 'state=4294967295 cpu_id=1', | |
| 309 ' <idle>-0 [001] 15050.993279: cpu_idle: ' + | |
| 310 'state=3 cpu_id=1', | |
| 311 ' <idle>-0 [001] 15050.993457: cpu_idle: ' + | |
| 312 'state=4294967295 cpu_id=1', | |
| 313 ]; | |
| 314 var m = new tracing.TimelineModel(lines.join('\n'), false); | |
| 315 assertEquals(0, m.importErrors.length); | |
| 316 | |
| 317 var c0 = m.cpus[0]; | |
| 318 assertEquals(0, c0.slices.length); | |
| 319 assertEquals(2, c0.counters['C-State'].samples.length); | |
| 320 | |
| 321 var c1 = m.cpus[1]; | |
| 322 assertEquals(0, c1.slices.length); | |
| 323 assertEquals(4, c1.counters['C-State'].samples.length); | |
| 324 } | |
| 325 | |
| 326 function testi915Import() { | |
| 327 var lines = [ | |
| 328 // NB: spliced from different traces; mismatched timestamps don't matter | |
| 329 ' chrome-1223 [000] 2784.773556: i915_gem_object_pwrite: ' + | |
| 330 'obj=ffff88013f13fc00, offset=0, len=2984', | |
| 331 ' chrome-1539 [000] 18420.677750: ' + | |
| 332 'i915_gem_object_change_domain: ' + | |
| 333 'obj=ffff8800a88d1400, read=44=>40, write=00=>40', | |
| 334 ' chrome-1539 [000] 18420.677759: i915_gem_object_fault: ' + | |
| 335 'obj=ffff8800a88d1400, GTT index=0 , writable', | |
| 336 ' X-964 [000] 2784.774864: i915_flip_request: ' + | |
| 337 'plane=0, obj=ffff88013f0b9a00', | |
| 338 ' <idle>-0 [000] 2784.788644: i915_flip_complete: ' + | |
| 339 'plane=0, obj=ffff88013f0b9a00', | |
| 340 ' chrome-1539 [001] 18420.681687: i915_gem_request_retire: ' + | |
| 341 'dev=0, ring=1, seqno=1178152', | |
| 342 ' chrome-1539 [000] 18422.955688: i915_gem_request_add: ' + | |
| 343 'dev=0, ring=1, seqno=1178364', | |
| 344 ' cat-21833 [000] 18422.956832: i915_gem_request_complete: ' + | |
| 345 'dev=0, ring=1, seqno=1178364', | |
| 346 ' X-1012 [001] 18420.682511: i915_gem_request_wait_begin: ' + | |
| 347 'dev=0, ring=4, seqno=1178156', | |
| 348 ' X-1012 [000] 18422.765707: i915_gem_request_wait_end: ' + | |
| 349 'dev=0, ring=4, seqno=1178359', | |
| 350 ' chrome-1539 [000] 18422.955655: i915_gem_ring_flush: ' + | |
| 351 'dev=0, ring=1, invalidate=001e, flush=0040', | |
| 352 ' chrome-1539 [000] 18422.955660: i915_gem_ring_dispatch: ' + | |
| 353 'dev=0, ring=1, seqno=1178364', | |
| 354 ' chrome-1539 [000] 18420.677772: i915_reg_rw: ' + | |
| 355 'write reg=0x100030, len=8, val=(0xfca9001, 0xfce8007)', | |
| 356 ' chrome-2465 [000] 71.653157: drm_vblank_event: ' + | |
| 357 'crtc=0, seq=4233', | |
| 358 ' <idle>-0 [000] 71.669851: drm_vblank_event: ' + | |
| 359 'crtc=0, seq=4234' | |
| 360 ]; | |
| 361 var m = new tracing.TimelineModel(lines.join('\n'), false); | |
| 362 assertEquals(0, m.importErrors.length); | |
| 363 | |
| 364 // For hand-assigned pseudo PID's+TID's. | |
| 365 var exports = tracing._LinuxPerfImporterTestExports; | |
| 366 | |
| 367 var kernelProc = m.processes[exports.pseudoKernelPID]; | |
| 368 | |
| 369 var i915GemThread = kernelProc.threads[exports.pseudoI915GemObjectTID]; | |
| 370 assertEquals('i915_gem', i915GemThread.name); | |
| 371 assertEquals(1, i915GemThread.subRows.length); | |
| 372 | |
| 373 var i915FlipThread = kernelProc.threads[exports.pseudoI915FlipTID]; | |
| 374 assertEquals('i915_flip', i915FlipThread.name); | |
| 375 assertEquals(1, i915FlipThread.subRows.length); | |
| 376 | |
| 377 assertAlmostEquals(2784.774864 * 1000.0, | |
| 378 i915FlipThread.subRows[0][0].start); | |
| 379 assertAlmostEquals((2784.788644 - 2784.774864) * 1000.0, | |
| 380 i915FlipThread.subRows[0][0].duration); | |
| 381 | |
| 382 var i915RegThread = kernelProc.threads[exports.pseudoI915RegTID]; | |
| 383 assertEquals('i915_reg', i915RegThread.name); | |
| 384 assertEquals(1, i915RegThread.subRows.length); | |
| 385 | |
| 386 var vblankThread = kernelProc.threads[exports.pseudoVblankTID]; | |
| 387 assertEquals('drm_vblank', vblankThread.name); | |
| 388 assertEquals(1, vblankThread.subRows.length); | |
| 389 } | |
| 390 | |
| 391 </script> | |
| 392 </body> | |
| 393 </html> | |
| OLD | NEW |