Skip to content

Commit

Permalink
fix fail to correct gfxinfo with Android6
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa committed Jan 10, 2016
1 parent c988077 commit 0c3692a
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 20 deletions.
20 changes: 10 additions & 10 deletions lib/droid/monitor/gfxinfo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
[]
Expand Down Expand Up @@ -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
Expand Down
87 changes: 77 additions & 10 deletions test/gfxinfo_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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," +
Expand All @@ -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\"}," +
Expand All @@ -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\"}," +
Expand All @@ -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\"}," +
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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

0 comments on commit 0c3692a

Please sign in to comment.