From 0c3692a4890f0e63cc4b7f89b4a5e3d343d37364 Mon Sep 17 00:00:00 2001 From: Kazuaki MATSUO Date: Sun, 10 Jan 2016 21:18:36 +0900 Subject: [PATCH] fix fail to correct gfxinfo with Android6 --- lib/droid/monitor/gfxinfo.rb | 20 ++++----- test/gfxinfo_test.rb | 87 +++++++++++++++++++++++++++++++----- 2 files changed, 87 insertions(+), 20 deletions(-) diff --git a/lib/droid/monitor/gfxinfo.rb b/lib/droid/monitor/gfxinfo.rb index f92318b..9197ede 100644 --- a/lib/droid/monitor/gfxinfo.rb +++ b/lib/droid/monitor/gfxinfo.rb @@ -21,15 +21,15 @@ def clear_gfxinfo_usage end def dump_gfxinfo_usage(dump_data) - scanned_dump1 = dump_data.scan(/^.*views,.*kB of display lists,.*frames rendered.*$/).map(&:strip).first - scanned_dump2 = dump_data.scan(/^.*bytes,.*MB.*$/).map(&:strip).first + view_dump = dump_data.scan(/^.*views,.*kB of display lists.*$/).map(&:strip).first + view_memory_dump2 = dump_data.scan(/^.*bytes,.*MB.*$/).map(&:strip).first - return [] if scanned_dump1.nil? || scanned_dump2.nil? + return [] if view_dump.nil? || view_memory_dump2.nil? - dump1 = scanned_dump1.split(/\s/).reject(&:empty?) - dump2 = scanned_dump2.split(/\s/).reject(&:empty?) + v_dump = view_dump.split(/\s/).reject(&:empty?) + v_mem_dump = view_memory_dump2.split(/\s/).reject(&:empty?) - dump1 + dump2 + v_mem_dump + v_dump rescue StandardError => e puts e [] @@ -64,10 +64,10 @@ def transfer_total_gfxinfo_to_hash(dump_gfxinfo_array) } else { - view: dump_gfxinfo_array[0].to_i, - display_lists_kb: dump_gfxinfo_array[2].to_f.round(2), - frames_rendered: dump_gfxinfo_array[7].to_i, - total_memory: (dump_gfxinfo_array[10].to_f / 1024).round(2), + view: dump_gfxinfo_array[4].to_i, + display_lists_kb: dump_gfxinfo_array[6].to_f.round(2), + frames_rendered: dump_gfxinfo_array[11].to_i || 0, + total_memory: (dump_gfxinfo_array[0].to_f / 1024).round(2), time: dump_gfxinfo_array.last, } end diff --git a/test/gfxinfo_test.rb b/test/gfxinfo_test.rb index f97af16..5a5927a 100644 --- a/test/gfxinfo_test.rb +++ b/test/gfxinfo_test.rb @@ -91,6 +91,69 @@ Total DisplayList: 1.36 kB EOS +SAMPLE_GFXINFO_6 = <<-EOS +Applications Graphics Acceleration Info: +Uptime: 9658130 Realtime: 9658130 + +** Graphics info for pid 9702 [com.android.chrome] ** + +Stats since: 9656484850794ns +Total frames rendered: 3 +Janky frames: 2 (66.67%) +90th percentile: 101ms +95th percentile: 101ms +99th percentile: 101ms +Number Missed Vsync: 2 +Number High input latency: 0 +Number Slow UI thread: 2 +Number Slow bitmap uploads: 0 +Number Slow issue draw commands: 1 + +Caches: +Current memory usage / total memory usage (bytes): + TextureCache 878276 / 75497472 + LayerCache 0 / 50331648 (numLayers = 0) + Layers total 0 (numLayers = 0) + RenderBufferCache 0 / 8388608 + GradientCache 0 / 1048576 + PathCache 0 / 33554432 + TessellationCache 0 / 1048576 + TextDropShadowCache 0 / 6291456 + PatchCache 0 / 131072 + FontRenderer 0 A8 1048576 / 1048576 + FontRenderer 0 RGBA 0 / 0 + FontRenderer 0 total 1048576 / 1048576 +Other: + FboCache 0 / 0 +Total memory usage: + 1926852 bytes, 1.84 MB + +Profile data in ms: + + com.android.chrome/org.chromium.chrome.browser.firstrun.FirstRunActivityStaging/android.view.ViewRootImpl@6b40547 (visibility=0) +Stats since: 9656484850794ns +Total frames rendered: 3 +Janky frames: 2 (66.67%) +90th percentile: 101ms +95th percentile: 101ms +99th percentile: 101ms +Number Missed Vsync: 2 +Number High input latency: 0 +Number Slow UI thread: 2 +Number Slow bitmap uploads: 0 +Number Slow issue draw commands: 1 + +View hierarchy: + + com.android.chrome/org.chromium.chrome.browser.firstrun.FirstRunActivityStaging/android.view.ViewRootImpl@6b40547 + 21 views, 31.36 kB of display lists + + +Total ViewRootImpl: 1 +Total Views: 21 +Total DisplayList: 31.36 kB +EOS + class GfxinfoTest < Test::Unit::TestCase def setup @@ -112,10 +175,16 @@ def test_initialize end def test_dump_gfxinfo_usage - expected = %w(41 views, 1.36 kB of display lists, 191 frames rendered 654464 bytes, 0.62 MB) + expected = %w(654464 bytes, 0.62 MB 41 views, 1.36 kB of display lists, 191 frames rendered) + assert_equal(expected, @gfx.dump_gfxinfo_usage(SAMPLE_GFXINFO)) end + def test_dump_gfxinfo_usage_for_API23 + expected = %w(1926852 bytes, 1.84 MB 21 views, 31.36 kB of display lists) + assert_equal(expected, @gfx.dump_gfxinfo_usage(SAMPLE_GFXINFO_6)) + end + def test_push_current_time assert_equal(@gfx.merge_current_time({}).length, 1) end @@ -130,7 +199,7 @@ def test_transfer_from_hash_empty_to_json end def test_transfer_from_hash_correct_to_json - dummy_array = %w(465 views, 38.00 kB of display lists, 354 frames rendered 5781894 bytes, 5.51 MB 13:43:32.556) + dummy_array = %w(5781894 bytes, 5.51 MB 465 views, 38.00 kB of display lists, 354 frames rendered 13:43:32.556) @gfx.store_gfxinfo_usage(dummy_array) expected_json = "[{\"view\":465,\"display_lists_kb\":38.0,\"frames_rendered\":354," + @@ -139,7 +208,7 @@ def test_transfer_from_hash_correct_to_json end def test_convert_to_google_data_api_format_gfx_one - dummy_array = %w(465 views, 38.00 kB of display lists, 354 frames rendered 5781894 bytes, 5.51 MB 13:43:32.556) + dummy_array = %w(5781894 bytes, 5.51 MB 465 views, 38.00 kB of display lists, 354 frames rendered 13:43:32.556) @gfx.store_gfxinfo_usage(dummy_array) expected_json = "{\"cols\":[{\"label\":\"time\",\"type\":\"string\"},{\"label\":\"view\",\"type\":\"number\"}," + @@ -149,7 +218,7 @@ def test_convert_to_google_data_api_format_gfx_one end def test_convert_to_google_data_api_format_mem_one - dummy_array = %w(465 views, 38.00 kB of display lists, 354 frames rendered 5781894 bytes, 5.51 MB 13:43:32.556) + dummy_array = %w(5781894 bytes, 5.51 MB 465 views, 38.00 kB of display lists, 354 frames rendered 13:43:32.556) @gfx.store_gfxinfo_usage(dummy_array) expected_json = "{\"cols\":[{\"label\":\"time\",\"type\":\"string\"}," + @@ -159,7 +228,7 @@ def test_convert_to_google_data_api_format_mem_one end def test_convert_to_google_data_api_format_frame_one - dummy_array = %w(465 views, 38.00 kB of display lists, 354 frames rendered 5781894 bytes, 5.51 MB 13:43:32.556) + dummy_array = %w(5781894 bytes, 5.51 MB 465 views, 38.00 kB of display lists, 354 frames rendered 13:43:32.556) @gfx.store_gfxinfo_usage(dummy_array) expected_json = "{\"cols\":[{\"label\":\"time\",\"type\":\"string\"}," + @@ -169,7 +238,7 @@ def test_convert_to_google_data_api_format_frame_one end def test_convert_to_google_data_api_format_gfx_many - dummy_array = %w(465 views, 38.00 kB of display lists, 354 frames rendered 5781894 bytes, 5.51 MB 13:43:32.556) + dummy_array = %w(5781894 bytes, 5.51 MB 465 views, 38.00 kB of display lists, 354 frames rendered 13:43:32.556) @gfx.store_gfxinfo_usage(dummy_array) @gfx.store_gfxinfo_usage(dummy_array) @@ -181,7 +250,7 @@ def test_convert_to_google_data_api_format_gfx_many end def test_convert_to_google_data_api_format_mem_many - dummy_array = %w(465 views, 38.00 kB of display lists, 354 frames rendered 5781894 bytes, 5.51 MB 13:43:32.556) + dummy_array = %w(5781894 bytes, 5.51 MB 465 views, 38.00 kB of display lists, 354 frames rendered 13:43:32.556) @gfx.store_gfxinfo_usage(dummy_array) @gfx.store_gfxinfo_usage(dummy_array) @@ -192,7 +261,7 @@ def test_convert_to_google_data_api_format_mem_many end def test_convert_to_google_data_api_format_frame_many - dummy_array = %w(465 views, 38.00 kB of display lists, 354 frames rendered 5781894 bytes, 5.51 MB 13:43:32.556) + dummy_array = %w(5781894 bytes, 5.51 MB 465 views, 38.00 kB of display lists, 354 frames rendered 13:43:32.556) @gfx.store_gfxinfo_usage(dummy_array) @gfx.store_gfxinfo_usage(dummy_array) @@ -201,6 +270,4 @@ def test_convert_to_google_data_api_format_frame_many "{\"v\":354}]},{\"c\":[{\"v\":\"#{@gfx.gfxinfo_usage[1][:time]}\"},{\"v\":354}]}]}" assert_equal(@gfx.export_as_google_api_format_frame(@gfx.gfxinfo_usage), expected_json) end - - end