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

网站seo具体怎么做怎样创建自己的电商平台

网站seo具体怎么做,怎样创建自己的电商平台,网站设计公司北京,移动端企业网站模板下载【性能工具】一种简易hook bitmap创建的插件使用 一、插件开源地址:二、插件引入:三、编写插桩代码四、编写调用demo代码,验证插桩效果 一、插件开源地址: https://github.com/DarkAdventurerr/lancet 二、插件引入:…

【性能工具】一种简易hook bitmap创建的插件使用

    • 一、插件开源地址:
    • 二、插件引入:
    • 三、编写插桩代码
    • 四、编写调用demo代码,验证插桩效果

一、插件开源地址:

https://github.com/DarkAdventurerr/lancet

二、插件引入:

  • 1、rootProject/build.gradle
classpath 'com.github.HairySnow.lancet:lancet-plugin:1.0.3'
  • 2、app/build.gradle
apply plugin: 'com.hairysnow.lancet'
// 添加库依赖
compileOnly 'com.github.HairySnow.lancet:lancet-base:1.0.3'

三、编写插桩代码

因为加载Bitmap基本都要经过Bitmap.create()方法创建Bitmap对象,所以只需hook Bitmap.createBitmap方法的所有重载方法即可监控到图片的创建过程,在hook方法执行到时,通过width * height * 图片位深度的方式就可以计算出bitmap的内存占用大小。

@TargetClass(value = “android.graphics.Bitmap”) 注解指定要插桩的类全路径,可以通过AS查找到这个类后鼠标放在类名上右键选择copy Reference就可以拿到该注解需要传入的参数值
@Proxy(value = “createBitmap”) 注解指定要插桩的类的具体方法名
一般来说使用Glide加载图片用到的是createBitmap(int width, int height, Bitmap.Config config)这个重载方法的实现。

public class BitmapHook {@TargetClass(value = "android.graphics.Bitmap")@Proxy(value = "createBitmap")public static Bitmap createBitmap(Bitmap source) {float factor = 1;if (source.getConfig().name().equals(Bitmap.Config.ARGB_8888.name())) {factor = 4;} else if (source.getConfig().name().equals(Bitmap.Config.ARGB_4444.name()) || source.getConfig().name().equals(Bitmap.Config.RGB_565.name())) {factor = 2;} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && source.getConfig().name().equals(Bitmap.Config.RGBA_F16.name())) {factor = 8;}int width = source.getWidth();int height = source.getHeight();float size = width * height * factor / (1024f * 1024f);Log.i("BitmapHook", "createBitmap: size = " + size + ", w = " + width + ", h = " + height);return (Bitmap) Origin.call();}@TargetClass(value = "android.graphics.Bitmap")@Proxy(value = "createBitmap")public static Bitmap createBitmap(Bitmap source, int x, int y, int width, int height) {float factor = 1;if (source.getConfig().name().equals(Bitmap.Config.ARGB_8888.name())) {factor = 4;} else if (source.getConfig().name().equals(Bitmap.Config.ARGB_4444.name()) || source.getConfig().name().equals(Bitmap.Config.RGB_565.name())) {factor = 2;} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && source.getConfig().name().equals(Bitmap.Config.RGBA_F16.name())) {factor = 8;}float size = width * height * factor / (1024f * 1024f);Log.i("BitmapHook", "createBitmap: size = " + size + ", w = " + width + ", h = " + height);return (Bitmap) Origin.call();}@TargetClass(value = "android.graphics.Bitmap")@Proxy(value = "createBitmap")public static Bitmap createBitmap(int width, int height, Bitmap.Config config) {float factor = 1;if (config.name().equals(Bitmap.Config.ARGB_8888.name())) {factor = 4;} else if (config.name().equals(Bitmap.Config.ARGB_4444.name()) || config.name().equals(Bitmap.Config.RGB_565.name())) {factor = 2;} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && config.name().equals(Bitmap.Config.RGBA_F16.name())) {factor = 8;}float size = width * height * factor / (1024f * 1024f);Log.i("BitmapHook", "createBitmap: size = " + size + "MB, w = " + width + ", h = " + height);return (Bitmap) Origin.call();}
}

ps: 上面并没有hook createBitmap所有重载方法,只是贴上了常见的,有新增需按照如上模板代码添加实现。

四、编写调用demo代码,验证插桩效果

BitmapHookActivity代码:

class BitmapHookActivity : AppCompatActivity() {override fun onCreate(savedInstanceState: Bundle?) {super.onCreate(savedInstanceState)setContentView(R.layout.activity_bitmap_hook)val imageView = findViewById<ImageView>(R.id.imageview)Glide.with(this@BitmapHookActivity).load(R.drawable.test).override(1920, 1080).into(imageView)}
}

输出:

2025-05-07 19:30:18.776 28613-28700 BitmapHook        com.demo.leanbackdemo       I  createBitmap: size = 3.1723022MB, w = 770, h = 1080

如上输出就拿到了使用Glide加载的Bitmap对象的内存占用大小,然后增加判断超过内存占用阈值的bitmap,可以增加一些后台上报信息。

http://www.dtcms.com/wzjs/249120.html

相关文章:

  • 建功能网站seo优化平台
  • 网站建设性意见表百度官方平台
  • 微信公众号 手机网站开发曹操论坛seo
  • c2c的盈利模式英文seo
  • 电脑上做网站百度指数官网登录
  • 企业形象网站怎么做网络营销的渠道
  • 新氧网站头图怎么做的优化网站排名方法
  • 网站详细报价如何在百度提交自己的网站
  • 国内高端网站软文营销的经典案例
  • 做网站会员功能软文发稿系统
  • 做安防在哪个网站做广告呢百度游戏官网
  • apache php 多个网站系统优化的意义
  • 个人建站步骤厦门站长优化工具
  • 做网站的人 优帮云小红书怎么做关键词排名优化
  • 网购网站后台管理系统图片代理公司注册
  • 东营网站推广公司网站优化培训
  • 上海做网站的厦门网页搜索排名提升
  • 本地测试dedecms网站保存在dedeampz那里技术培训
  • 万户网络做网站如何爱战网官网
  • 网站建设服装在线商城实训报告如何提高搜索引擎优化
  • 做网站和做app哪个简单网络营销是什么?
  • 做门户网站cms盘多多搜索引擎入口
  • 英文网站建设方案模板高校长尾关键词排名推广
  • 做购物网站需要什么服务器百度识图网页版在线使用
  • 医院网站怎么做什么叫关键词
  • 网站建设 睿达科墨子学院seo
  • 手机壁纸网站大全百度地图在线使用
  • 如何美化网站百度快照的作用是什么
  • php mysql 网站源码三只松鼠有趣的软文
  • 嘉兴市平湖市建设局网站网站免费软件