summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--packages/astro/src/dev.ts8
-rw-r--r--packages/astro/src/runtime.ts8
2 files changed, 14 insertions, 2 deletions
diff --git a/packages/astro/src/dev.ts b/packages/astro/src/dev.ts
index 3a366ef00..17c72568d 100644
--- a/packages/astro/src/dev.ts
+++ b/packages/astro/src/dev.ts
@@ -7,8 +7,9 @@ import { green } from 'kleur/colors';
import http from 'http';
import path from 'path';
import { performance } from 'perf_hooks';
-import { defaultLogDestination, error, info, parseError } from './logger.js';
+import { defaultLogDestination, debug, error, info, parseError } from './logger.js';
import { createRuntime } from './runtime.js';
+import { stopTimer } from './build/util';
const hostname = '127.0.0.1';
@@ -24,11 +25,16 @@ const logging: LogOptions = {
export default async function dev(astroConfig: AstroConfig) {
const startServerTime = performance.now();
const { projectRoot } = astroConfig;
+ const timer: Record<string, number> = {};
+ timer.runtime = performance.now();
const runtime = await createRuntime(astroConfig, { mode: 'development', logging });
+ debug(logging, 'dev', `runtime created [${stopTimer(timer.runtime)}]`);
const server = http.createServer(async (req, res) => {
+ timer.load = performance.now();
const result = await runtime.load(req.url);
+ debug(logging, 'dev', `loaded ${req.url} [${stopTimer(timer.load)}]`);
switch (result.statusCode) {
case 200: {
diff --git a/packages/astro/src/runtime.ts b/packages/astro/src/runtime.ts
index 965ea641a..c1c833750 100644
--- a/packages/astro/src/runtime.ts
+++ b/packages/astro/src/runtime.ts
@@ -6,8 +6,9 @@ import type { AstroConfig, CollectionResult, CollectionRSS, CreateCollection, Pa
import { existsSync } from 'fs';
import { fileURLToPath } from 'url';
+import { performance } from 'perf_hooks';
import { loadConfiguration, logger as snowpackLogger, startServer as startSnowpackServer } from 'snowpack';
-import { canonicalURL } from './build/util.js';
+import { canonicalURL, stopTimer } from './build/util.js';
import { debug, info } from './logger.js';
import { searchForPage } from './search.js';
@@ -332,8 +333,10 @@ async function createSnowpack(astroConfig: AstroConfig, options: CreateSnowpackO
/** Core Astro runtime */
export async function createRuntime(astroConfig: AstroConfig, { mode, logging }: RuntimeOptions): Promise<AstroRuntime> {
+ const timer: Record<string, number> = {};
const resolvePackageUrl = async (pkgName: string) => frontendSnowpack.getUrlForPackage(pkgName);
+ timer.backend = performance.now();
const { snowpack: backendSnowpack, snowpackRuntime: backendSnowpackRuntime, snowpackConfig: backendSnowpackConfig } = await createSnowpack(astroConfig, {
env: {
astro: true,
@@ -341,13 +344,16 @@ export async function createRuntime(astroConfig: AstroConfig, { mode, logging }:
mode,
resolvePackageUrl,
});
+ debug(logging, 'core', `backend snowpack created [${stopTimer(timer.backend)}]`);
+ timer.frontend = performance.now();
const { snowpack: frontendSnowpack, snowpackRuntime: frontendSnowpackRuntime, snowpackConfig: frontendSnowpackConfig } = await createSnowpack(astroConfig, {
env: {
astro: false,
},
mode,
});
+ debug(logging, 'core', `frontend snowpack created [${stopTimer(timer.frontend)}]`);
const runtimeConfig: RuntimeConfig = {
astroConfig,