Skip to content

Commit

Permalink
fixbug: index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
linkxzhou committed Mar 24, 2024
1 parent 980f2d7 commit c21e63b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
9 changes: 7 additions & 2 deletions http_bench.go
Original file line number Diff line number Diff line change
Expand Up @@ -791,10 +791,15 @@ func main() {
_, mainCancel := context.WithCancel(context.Background())

// decrease go gc rate
benchGOGC := getEnv("BENCH_GOGC")
if n, err := strconv.ParseInt(benchGOGC, 2, 64); err == nil {
stressGOGC := getEnv("STRESS_GOGC")
if n, err := strconv.ParseInt(stressGOGC, 2, 64); err == nil {
debug.SetGCPercent(int(n))
}
// cloud worker API
stressWorkerAPI := getEnv("STRESS_WORKERAPI")
if stressWorkerAPI != "" {
dashboardHtml = strings.ReplaceAll(dashboardHtml, "/api", stressWorkerAPI)
}

if len(*dashboard) > 0 {
*listen = *dashboard
Expand Down
31 changes: 16 additions & 15 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@
<el-input placeholder="request url" v-model="url" style="margin: 4px 0;">
<template slot="prepend">Stress Url</template>
</el-input>
<el-input placeholder="default https://service-akrbbnzg-1251014631.gz.tencentapigw.com.cn/" v-model="apinode_path" style="margin: 4px 0;">
<template slot="prepend">API Node Path</template>
<el-input placeholder="/api" v-model="worker_api" style="margin: 4px 0;">
<template slot="prepend">Worker API</template>
</el-input>
</div>
<script type="text/javascript">
Date.prototype.format = function (fmt) {
var o = {
let o = {
"M+": this.getMonth() + 1,
"d+": this.getDate(),
"h+": this.getHours(),
Expand All @@ -71,7 +71,7 @@
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for (var k in o) {
for (let k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
}
Expand All @@ -80,7 +80,8 @@
}

const contentType = { 'Content-Type': 'application/json;charset=utf-8' };
const defaultAPINodePath = "https://service-akrbbnzg-1251014631.gz.tencentapigw.com.cn/api";
const workerApiPath = "/api";

let dom = document.getElementById('container');
let stressChart = echarts.init(dom, 'dark', {
renderer: 'canvas',
Expand Down Expand Up @@ -148,7 +149,7 @@
auth_username: "",
auth_password: "",
url: "http://127.0.0.1:8000?data=1",
apinode_path: "",
worker_api: "",
g_running: false,
g_seqid: Math.floor(Math.random() * 1000000) + 1,
g_interval: undefined,
Expand All @@ -174,12 +175,12 @@
url: this.url,
};

let apinode_path = defaultAPINodePath;
if (this.apinode_path.length > 0) {
apinode_path = this.apinode_path;
let worker_api = workerApiPath;
if (this.worker_api.length > 0) {
worker_api = this.worker_api;
}

fetch(apinode_path, {
fetch(worker_api, {
method: 'POST',
headers: contentType,
body: JSON.stringify(request_data)
Expand All @@ -205,7 +206,7 @@
this.g_running = true;
this.g_interval = setInterval(function () {
request_data.cmd = 2; // get metrics
fetch(apinode_path, {
fetch(worker_api, {
method: 'POST',
headers: contentType,
body: JSON.stringify(request_data)
Expand Down Expand Up @@ -242,12 +243,12 @@
sequence_id: this.g_seqid,
};

let apinode_path = defaultAPINodePath;
if (this.apinode_path.length > 0) {
apinode_path = this.apinode_path;
let worker_api = workerApiPath;
if (this.worker_api.length > 0) {
worker_api = this.worker_api;
}

fetch(apinode_path, {
fetch(worker_api, {
method: 'POST',
headers: contentType,
body: JSON.stringify(request_data)
Expand Down

0 comments on commit c21e63b

Please sign in to comment.