Skip to content

Commit

Permalink
Build Timers
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuyk committed Oct 12, 2023
1 parent 3b4a2a6 commit a947b79
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions scripts/runtime/index.js
Expand Up @@ -4,6 +4,8 @@ import fs from 'fs';
import crypto from 'crypto';
import { globSync } from '../shared/fileHelpers.js';

const DEBUG = true;

const NO_SPECIAL_CHARACTERS = new RegExp(/^[ A-Za-z0-9_-]*$/gm);

const ports = [7788, 'altv-server', 'altv-server.exe', 3399, 3001];
Expand Down Expand Up @@ -46,6 +48,15 @@ let previousGlobFiles = [];

let fileWatchTimeout = Date.now() + 1000;

function createExecTime(name) {
const startTime = Date.now();
return {
stop: () => {
console.log(`${name} - ${Date.now() - startTime}ms`);
},
};
}

async function sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
Expand Down Expand Up @@ -215,16 +226,24 @@ async function refreshFileWatching() {
async function coreBuildProcess() {
const start = Date.now();

const coreCompilerTime = createExecTime('>>> core-compiler');
await runFile(node, './scripts/compiler/core');
coreCompilerTime.stop();

const pluginBuildTime = createExecTime('>>> core-plugins');
await runFile(node, './scripts/plugins/core');
pluginBuildTime.stop();

const mixedTime = createExecTime('>>> plugin webview, tranform, files');
const promises = [
runFile(node, './scripts/plugins/webview'),
runFile(node, './scripts/transform/index'),
runFile(node, './scripts/plugins/files'),
];

await Promise.all(promises);
mixedTime.stop();

await runFile(node, './scripts/transform/index');
console.log(`Build Time - ${Date.now() - start}ms`);
}
Expand Down Expand Up @@ -255,15 +274,22 @@ async function runServer() {
const isDev = passedArguments.includes('dev');

//Update dependencies for all the things
const updateTime = createExecTime('>>> update-dependencies');
await runFile(node, './scripts/plugins/update-dependencies');
updateTime.stop();

if (isDev) {
handleViteDevServer();
}

// Has to build first before building the rest.
const coreBuildTime = createExecTime('>>> core-build-time');
await coreBuildProcess();
coreBuildTime.stop();

const configurationTime = createExecTime('>>> handle-configuration-time');
await handleConfiguration();
configurationTime.stop();

if (passedArguments.includes('dev')) {
await sleep(50);
Expand Down

0 comments on commit a947b79

Please sign in to comment.