首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有没有办法通过点击事件多次运行Boomerang (由AKAMAI提供)?

有没有办法通过点击事件多次运行Boomerang (由AKAMAI提供)?
EN

Stack Overflow用户
提问于 2020-08-31 15:39:06
回答 1查看 46关注 0票数 0

目前,我有一个点击事件,当一个按钮被点击时,它会运行回飞棒带宽指标,但我有一个问题,它只会在第一次运行,直到我刷新我的页面。它是不能多次运行,还是我遗漏了什么?

我只想记录网络指标,而不想记录其他信息。

这里有一个指向存储库/文档的链接:https://akamai.github.io/boomerang/BOOMR.plugins.BW.html

以下是on-click事件:

代码语言:javascript
复制
$('#boomerangTest').on('click', function (event) {
        debugger
        //var pathname = window.location.pathname;
        //var url = window.location.href;
        //var origin = window.location.origin;
        //var imageURL = origin + '';

        var loc = window.location.pathname;
        var dir = loc.substring(0, loc.lastIndexOf('/'));
        var imageURL = dir + "/assets/images/boomr/"

        var data = {
            UserName: cb.Win.FindHandleID('#spanUserName').html().replace('Logged in as: ', '')
        };

        data.UserName = data.UserName.substr(0, data.UserName.indexOf('(')).trim();

        if (data.UserName === '') {
            cb.Win.ErrDialog('Network Metrics', 'Please Login before running a network test');
        }
        else {
            $('#main_content').cbAjaxLoader('big');
            BOOMR.init({
                beacon_url: '',
                 BW: {
                     base_url: imageURL,
                     block_beacon: true,
                     cookie: "AK_BW"
                 },
                 RT: {
                     enabled: true,
                     clearOnBeacon: true
                 }
             });

            BOOMR.subscribe('before_beacon', function (o) {
                debugger
                var html = "",
                    t_name,
                    t_other,
                    others = [],
                    bandwidthMetrics = {};

                if (!o.t_other) o.t_other = "";

                for (var k in o) {
                    if (!k.match(/^(t_done|t_other|bw|lat|bw_err|lat_err|u|r2?)$/)) {
                        if (k.match(/^t_/)) {
                            o.t_other += "," + k + "|" + o[k];
                        }
                        else {
                            others.push(k + " = " + o[k]);
                        }
                    }
                }

                if (o.t_done) {
                    html += "This page took " + o.t_done + " ms to load<br>";
                    bandwidthMetrics.LoadDuration = o.t_done;
                }

                if (o.bw) {
                    html += "Your bandwidth to this server is " + parseInt(o.bw / 1024) + " kbps (&#x00b1;" + parseInt(o.bw_err * 100 / o.bw) + "%)<br>";
                    bandwidthMetrics.DownSpeed = parseInt(o.bw / 1024);
                }

                if (o.lat) {
                    html += "Your latency to this server is " + parseInt(o.lat) + " ms (&#x00b1;" + parseInt(o.lat_err * 100 / o.lat) + "%)<br>";
                    bandwidthMetrics.Latency = parseInt(o.lat);
                }

                cb.Win.ErrDialog('Network Metric Results', html, 'main_content');
                $('#main_content').cbAjaxLoaderRemove();

            });

            $('#main_content').cbAjaxLoaderRemove();
        }
    });
EN

回答 1

Stack Overflow用户

发布于 2020-09-19 01:25:21

boomerang将结果存储在cookie中,并且在7天内不会在同一网络上重新运行测试。如果您需要它来重新运行测试,则禁用BW cookie。

请注意,boomerang团队很少监控Stackoverflow,通过直接发布到github问题列表,您将获得更快的响应。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63666686

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档