-
Notifications
You must be signed in to change notification settings - Fork 78
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
208 additions
and
1,035 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import os from 'os'; | ||
import fs from 'fs/promises'; | ||
|
||
let len = 1_000_000; | ||
const fileName = `entries-${Date.now()}`; | ||
|
||
async function addEntry () { | ||
const entry = { | ||
timestamp: Date.now(), | ||
memory: os.freemem(), | ||
totalMemory: os.totalmem(), | ||
uptime: os.uptime(), | ||
}; | ||
|
||
await fs.appendFile(fileName, JSON.stringify(entry) + '\n'); | ||
} | ||
|
||
async function summary () { | ||
const stats = await fs.lstat(fileName); | ||
console.log(`File size: ${stats.size} bytes! \n`); | ||
} | ||
|
||
// execution | ||
(async () => { | ||
await fs.writeFile(fileName, "----START---\n"); | ||
while (len > 0) { | ||
await addEntry(); | ||
process.stdout.write(`~~> ${len} entries to record\r`); | ||
len--; | ||
}; | ||
|
||
await summary(); | ||
})(); | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import os from 'os'; | ||
|
||
let len = 1_000_000; | ||
const entries = new Set(); | ||
|
||
function addEntry () { | ||
const entry = { | ||
timestamp: Date.now(), | ||
memory: os.freemem(), | ||
totalMemory: os.totalmem(), | ||
uptime: os.uptime(), | ||
}; | ||
|
||
entries.add(entry); | ||
} | ||
|
||
function summary () { | ||
console.log(`Total: ${entries.size} entries`); | ||
} | ||
|
||
// execution | ||
(() => { | ||
while (len > 0) { | ||
addEntry(); | ||
process.stdout.write(`~~> ${len} entries to record\r`); | ||
len--; | ||
}; | ||
|
||
summary(); | ||
})(); | ||
|
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.