Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何把结果写成文件 #10

Open
dengzhao7053 opened this issue May 15, 2017 · 7 comments
Open

如何把结果写成文件 #10

dengzhao7053 opened this issue May 15, 2017 · 7 comments

Comments

@dengzhao7053
Copy link

你好,我的项目不是运行在手机上的,无法展示出结果的那个界面,请问如果我想把结果写入一个文件中,在哪修改呢

@seiginonakama
Copy link
Owner

seiginonakama commented May 15, 2017

    /**
     * Path to save log, like "/blockcanary/", will save to sdcard if can. if we can't save log to sdcard (eg: no permission),
     * else we will try to save to "${context.getExternalFilesDir("BlockCanaryEx")}${provideLogPath()}", if we failed too,
     * we will save to "${context.getFilesDir()${provideLogPath()}"}"
     *
     * Note: running in none ui thread
     *
     * @return path of log files
     */
    public String provideLogPath() {
        return "/blockcanaryex/" + getContext().getPackageName() + "/";
    }

BlockCanary会自动把日志写到存储里面。
默认是/sdcard/blockcanaryex/<packageName>/。如果没有写权限,会写到/sdcard/Android/data/<packageName>/files/BlockCanaryEx/blockcanaryex。

@seiginonakama
Copy link
Owner

              /**
               * Block listener, developer may provide their own actions
               *
               * @param blockInfo {@link BlockInfo}
               */
              @Override
              public void onBlock(BlockInfo blockInfo) {
              }

如果没有ui界面,你可以复写Config的onBlock方法监听卡顿事件,把blockInfo打印到logcat也可以。

@dengzhao7053
Copy link
Author

谢谢谢谢,其实问完问题后就找到了那个文件,之前没有仔细看代码。。。。。。

还有一个问题,代码里边有好多 mRandom.nextInt(Integer.MAX_VALUE); 产生随机数,这个我没看懂,不知道用来干嘛的。。。本人android菜鸟一枚 原谅哈

@seiginonakama
Copy link
Owner

单纯模拟计算耗时操作。

@dengzhao7053
Copy link
Author

感谢up主分享这些好的东西,还有一个小小的问题:
[93%] Fragment.onCreateView(LayoutInflater,ViewGroup,Bundle) costRealTime:333ms costThreadTime:238ms
以上是我的结果之一,我想知道 [93%] 代表什么,costRealTime和costThreadTime有什么区别吗?再次感谢

@dengzhao7053
Copy link
Author

运行了你的demo,发现每个方法耗时结果点击后会有更详细的信息,这个在/sdcard/blockcanaryex//下的文件里似乎没有,请问如果我想得到这些更详细的信息,打印blockInfo可以吗

@seiginonakama
Copy link
Owner

文件里面已经是最全的信息了,界面里面的所有信息都来自文件

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants