Log timings
This commit is contained in:
parent
6d6100eaf4
commit
192d980e53
|
@ -4,7 +4,7 @@ const { createApp, getTable, createRow, createTable } = require("./utils")
|
||||||
const Chance = require("chance")
|
const Chance = require("chance")
|
||||||
const generator = new Chance()
|
const generator = new Chance()
|
||||||
|
|
||||||
const STUDENT_COUNT = 100
|
const STUDENT_COUNT = 500
|
||||||
const SUBJECT_COUNT = 10
|
const SUBJECT_COUNT = 10
|
||||||
|
|
||||||
if (!process.argv[2]) {
|
if (!process.argv[2]) {
|
||||||
|
@ -16,6 +16,8 @@ async function sleep(ms) {
|
||||||
return new Promise(r => setTimeout(() => r(), ms))
|
return new Promise(r => setTimeout(() => r(), ms))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const start = Date.now()
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
const apiKey = process.argv[2]
|
const apiKey = process.argv[2]
|
||||||
const app = await createApp(apiKey)
|
const app = await createApp(apiKey)
|
||||||
|
@ -44,7 +46,11 @@ async function run() {
|
||||||
"Attendance_(%)": generator.integer({ min: 0, max: 100 }),
|
"Attendance_(%)": generator.integer({ min: 0, max: 100 }),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
console.log(`Row ${i + 1} of ${STUDENT_COUNT} created`)
|
console.log(
|
||||||
|
`Student ${i + 1} of ${STUDENT_COUNT} created (${
|
||||||
|
(Date.now() - start) / 1000
|
||||||
|
}s)`
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const subjectTable = await createTable(apiKey, app._id, {
|
const subjectTable = await createTable(apiKey, app._id, {
|
||||||
|
@ -64,7 +70,11 @@ async function run() {
|
||||||
Name: generator.profession(),
|
Name: generator.profession(),
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
console.log(`Subject ${i + 1} of ${SUBJECT_COUNT} created`)
|
console.log(
|
||||||
|
`Subject ${i + 1} of ${SUBJECT_COUNT} created (${
|
||||||
|
(Date.now() - start) / 1000
|
||||||
|
}s)`
|
||||||
|
)
|
||||||
await sleep(50)
|
await sleep(50)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,13 +119,19 @@ async function run() {
|
||||||
Subject: [subject],
|
Subject: [subject],
|
||||||
})
|
})
|
||||||
console.log(
|
console.log(
|
||||||
`Grade ${++i} of ${students.length * subjects.length} created`
|
`Grade ${++i} of ${students.length * subjects.length} created (${
|
||||||
|
(Date.now() - start) / 1000
|
||||||
|
}s)`
|
||||||
)
|
)
|
||||||
await sleep(20)
|
await sleep(20)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
run().catch(err => {
|
run()
|
||||||
|
.then(() => {
|
||||||
|
console.log(`Done in(${(Date.now() - start) / 1000} seconds`)
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue