当前位置: 首页 > news >正文

PerfettoSQL

​​​​# Device State: Top App

# select id, ts, dur, name from (__query_slice_track__long_battery_tracing_Device_State_Top_app)

--> 简便方法
"""
INCLUDE PERFETTO MODULE android.battery_stats;
select * from android_battery_stats_event_slices where track_name='battery_stats.top';
"""--> 原始数据
"""
CREATE PERFETTO VIEW android_battery_stats_event_slices (-- Start of a new battery state.ts TIMESTAMP,-- The duration the state was active, -1 for incomplete slices.dur DURATION,-- The same as `dur`, but extends to trace end for incomplete slices.safe_dur DURATION,-- The name of the counter track.track_name STRING,-- String value.str_value STRING,-- Int value.int_value LONG
) AS
WITHevent_markers AS (SELECTts,track.name AS track_name,str_split(slice.name, '=', 1) AS key,substr(slice.name, 1, 1) = '+' AS startFROM sliceJOIN trackON slice.track_id = track.idWHEREtrack_name GLOB 'battery_stats.*' AND substr(slice.name, 1, 1) IN ('+', '-')),with_neighbors AS (SELECT*,lag(ts) OVER (PARTITION BY track_name, key ORDER BY ts) AS last_ts,lead(ts) OVER (PARTITION BY track_name, key ORDER BY ts) AS next_tsFROM event_markers),-- Note: query performance depends on the ability to push down filters on-- the track_name. It would be more clear below to have two queries and union-- them, but doing so prevents push down through the above window functions.event_spans AS (SELECTtrack_name,key,iif(start, ts, trace_start()) AS ts,iif(start, next_ts, ts) AS end_tsFROM with_neighbors-- For the majority of events, we take the `start` event and compute the dur-- based on next_ts. In the off chance we get an end event with no prior-- start (matched by the second half of this where), we can create an event-- starting from the beginning of the trace ending at the current event.WHERE(start OR last_ts IS NULL))
SELECTts,coalesce(end_ts - ts, -1) AS dur,coalesce(end_ts, trace_end()) - ts AS safe_dur,track_name,str_split(key, '"', 1) AS str_value,cast_int!(str_split(key, ':', 0)) AS int_value
FROM event_spans;select * from android_battery_stats_event_slices where track_name='battery_stats.top';
"""

# Android APP Startups

# select id, ts, dur, name from (__query_slice_track__android_startups)

-->
"""
INCLUDE PERFETTO MODULE android.startup.startups;
SELECT * FROM android_startups;
"""

相关文章:

  • 【RAG】一篇文章介绍多模态RAG(MRAG)
  • 电商虚拟户分账系统:破解电商资金管理难题的密钥
  • 蓝牙耳机开发--提示音制作生成的方法
  • 深入探索RAG:用LlamaIndex为大语言模型扩展知识,实现智能检索增强生成
  • Win10 关闭自动更新、关闭自动更新并重启
  • Jetson Orin NX 16G 配置GO1强化学习运行环境
  • 深度学习中的“重参数化”总结
  • 互联网大厂Java面试:软件架构与大型网站架构设计的较量
  • 操作系统-用户级-内核级线程
  • IOT项目——物联网 GPS
  • 25.4.22华为--算法真题整理(2025年4月22日)
  • 全本地化智能数字人
  • 一个 HTTP 请求进入 Spring MVC 应用后,大致经历了哪些主要步骤?
  • 电商平台数据采集与 QPS 计算全流程解析
  • 逻辑思维与软件开发:从选定方向到风险管理的全流程
  • Linux DRM显示驱动框架技术总结
  • 进阶篇 第 5 篇:现代预测方法 - Prophet 与机器学习特征工程
  • 今日CSS笔记
  • SAS宏调试:高效定位与解决典型问题
  • WLAN 漫游技术全解析:类型、转发模式与应用场景
  • 魔都眼|石库门里看车展,五一来张园体验城市“漫时光”
  • 体重管理门诊来了,瘦不下来的我们有救了?|健康有方FM
  • 巴西外长维埃拉:国际形势日益复杂,金砖国家必须发挥核心作用
  • 五一“拼假”催热超长假期,热门酒店民宿一房难求
  • 光明网评论员:手机“二次放号”,需要重新确认“你是你”
  • 走访中广核风电基地:701台风机如何乘风化电,点亮3000万人绿色生活