Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
small perf tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
mawburn committed Aug 1, 2021
1 parent bebd998 commit 95ff9cf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "ping-logger",
"version": "1.1.5",
"version": "1.1.6",
"description": "Display average ping in user list.",
"scripts": {
"clean": "rimraf dist module.zip",
Expand Down
8 changes: 4 additions & 4 deletions src/module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "ping-logger",
"title": "Ping Logger",
"description": "Display average ping in user list.",
"version": "1.1.5",
"version": "1.1.6",
"author": "hypnoCode",
"authors": [
{
Expand All @@ -18,10 +18,10 @@
],
"scripts": [],
"esmodules": [
"logger-O4BQO2BH.js"
"logger-MXM420itY.js"
],
"styles": [
"logger-O4BQO2BH.css"
"logger-MXM420itY.css"
],
"packs": [],
"languages": [],
Expand All @@ -30,7 +30,7 @@
"compatibleCoreVersion": "0.8.8",
"url": "https://github.com/mawburn/foundry-ping-logger",
"manifest": "https://raw.githubusercontent.com/mawburn/foundry-ping-logger/main/src/module.json",
"download": "https://github.com/mawburn/foundry-ping-logger/releases/download/v1.1.5/module.zip",
"download": "https://github.com/mawburn/foundry-ping-logger/releases/download/v1.1.6/module.zip",
"license": "GNU AGPLv3",
"readme": "https://github.com/mawburn/foundry-ping-logger/blob/main/README.md",
"bugs": "https://github.com/mawburn/foundry-ping-logger/issues",
Expand Down
16 changes: 5 additions & 11 deletions src/module/webping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,25 +45,19 @@ export class WebPing {
}

ping = async () => {
const startTime = new Date().getTime()

try {
const delta = await fetch(this.url, { method: 'HEAD' }).then(res => {
if (!res.ok) {
throw new Error('Bad response from server')
}

return new Date().getTime() - startTime
})
const startTime = Date.now()
await fetch(this.url, { method: 'HEAD' })
const delta = Date.now() - startTime

this.pingArr.push(delta)
this.pong((game as Game).user?.name, (game as Game).user?.id, this.average())
this.pong((game as Game).user?.id, this.average())
} catch (err) {
console.log(err)
}
}

pong(userName, userId, average) {
pong(userId, average) {
const pong: Pong = {
userId,
average,
Expand Down

0 comments on commit 95ff9cf

Please sign in to comment.