Skip to content

Commit 65ebd5c

Browse files
committed
Add timing logs
1 parent a07deff commit 65ebd5c

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/global-state.ts

+10-8
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ function createGlobalStateMachine() {
303303

304304
// Clone repo
305305
// This could take awhile if the repo is large
306-
console.log(`$ git clone ${url}.git ${ROOT_DIR}`)
306+
console.time(`$ git clone ${url}.git ${ROOT_DIR}`)
307307
await git.clone({
308308
fs,
309309
http,
@@ -316,6 +316,7 @@ function createGlobalStateMachine() {
316316
onMessage: console.log,
317317
onAuth: () => ({ username, password: token }),
318318
})
319+
console.timeEnd(`$ git clone ${url}.git ${ROOT_DIR}`)
319320

320321
// Set user in git config
321322
console.log(`$ git config user.name "Cole Bemis"`)
@@ -345,23 +346,24 @@ function createGlobalStateMachine() {
345346

346347
const { username, token } = context.githubUser
347348

348-
console.log(`$ git pull`)
349+
console.time(`$ git pull`)
349350
await git.pull({
350351
fs,
351352
http,
352353
dir: ROOT_DIR,
353354
singleBranch: true,
354-
onMessage: console.log,
355355
onAuth: () => ({ username, password: token }),
356356
})
357+
console.timeEnd(`$ git pull`)
357358

358-
console.log(`$ git push`)
359+
console.time(`$ git push`)
359360
await git.push({
360361
fs,
361362
http,
362363
dir: ROOT_DIR,
363364
onAuth: () => ({ username, password: token }),
364365
})
366+
console.timeEnd(`$ git push`)
365367

366368
const markdownFiles = await getMarkdownFilesFromFs(ROOT_DIR)
367369

@@ -397,13 +399,14 @@ function createGlobalStateMachine() {
397399

398400
// Push if online
399401
if (navigator.onLine) {
400-
console.log(`$ git push`)
402+
console.time(`$ git push`)
401403
await git.push({
402404
fs,
403405
http,
404406
dir: ROOT_DIR,
405407
onAuth: () => ({ username, password: token }),
406408
})
409+
console.timeEnd(`$ git push`)
407410
}
408411
},
409412
deleteFile: async (context, event) => {
@@ -436,13 +439,14 @@ function createGlobalStateMachine() {
436439

437440
// Push if online
438441
if (navigator.onLine) {
439-
console.log(`$ git push`)
442+
console.time(`$ git push`)
440443
await git.push({
441444
fs,
442445
http,
443446
dir: ROOT_DIR,
444447
onAuth: () => ({ username, password: token }),
445448
})
449+
console.timeEnd(`$ git push`)
446450
}
447451
},
448452
},
@@ -522,7 +526,6 @@ function getMarkdownFilesFromLocalStorage() {
522526
/** Walk the file system and return the contents of all markdown files */
523527
async function getMarkdownFilesFromFs(dir: string) {
524528
console.time("getMarkdownFilesFromFs()")
525-
526529
const markdownFiles = await git.walk({
527530
fs,
528531
dir,
@@ -542,7 +545,6 @@ async function getMarkdownFilesFromFs(dir: string) {
542545
return [filepath, new TextDecoder().decode(content)]
543546
},
544547
})
545-
546548
console.timeEnd("getMarkdownFilesFromFs()")
547549

548550
return Object.fromEntries(markdownFiles)

0 commit comments

Comments
 (0)