小编x64*_*x64的帖子

如何以编程方式访问chrome性能分析

寻找一些chrome API(用于chrome扩展),让我以编程方式执行以下操作: - 开始分析 - 结束分析 - 获取页面上所有JS所用的时间列表

我可以在Firefox中实现同样的目标:

jsd = DebuggerService.getService(jsdIDebuggerService)
// start the profiling as
jsd.flags |= COLLECT_PROFILE_DATA;

// stop the profilinf as
jsd.flags &= ~COLLECT_PROFILE_DATA;

// get the details of how much time each JS function took
jsd.enumerateScripts({enumerateScript: function(script)
{
// script object has timings detail
}
Run Code Online (Sandbox Code Playgroud)

甚至一些可以让我从开发人员工具栏导出分析信息的API也会有所帮助

javascript profiling google-chrome google-chrome-extension google-chrome-devtools

11
推荐指数
1
解决办法
3481
查看次数

了解Kafka流组by和window

我无法理解kafka流中的groupBy / groupById和窗口化的概念。我的目标是汇总一段时间(例如5秒)内的流数据。我的流数据看起来像:

{"value":0,"time":1533875665509}
{"value":10,"time":1533875667511}
{"value":8,"time":1533875669512}
Run Code Online (Sandbox Code Playgroud)

时间以毫秒(纪元)为单位。我的时间戳记在我的消息中,而不在密钥中。我想平均5秒窗口的值。

这是我正在尝试的代码,但似乎无法使它正常工作

builder.<String, String>stream("my_topic")
   .map((key, val) -> { TimeVal tv = TimeVal.fromJson(val); return new KeyValue<Long, Double>(tv.time, tv.value);})
   .groupByKey(Serialized.with(Serdes.Long(), Serdes.Double()))
   .windowedBy(TimeWindows.of(5000))
   .count()
   .toStream()
   .foreach((key, val) -> System.out.println(key + " " + val));
Run Code Online (Sandbox Code Playgroud)

即使主题每两秒钟生成一次消息,此代码也不会打印任何内容。当我按Ctrl + C时,它会打印出类似

[1533877059029@1533877055000/1533877060000] 1
[1533877061031@1533877060000/1533877065000] 1
[1533877063034@1533877060000/1533877065000] 1
[1533877065035@1533877065000/1533877070000] 1
[1533877067039@1533877065000/1533877070000] 1
Run Code Online (Sandbox Code Playgroud)

此输出对我来说没有意义。

相关代码:

public class MessageTimeExtractor implements TimestampExtractor {
    @Override
    public long extract(ConsumerRecord<Object, Object> record,  long previousTimestamp) {
        String str = (String)record.value();
        TimeVal tv = TimeVal.fromJson(str);
        return tv.time;
    }
}

public …
Run Code Online (Sandbox Code Playgroud)

java stream-processing apache-kafka apache-kafka-streams

2
推荐指数
1
解决办法
4357
查看次数