실행시간표시추가

This commit is contained in:
Insub Kim 2025-04-23 21:03:14 +09:00
parent 29541a1bec
commit 332dd12bb0

View File

@ -1,7 +1,7 @@
import fetch from 'node-fetch';
import postgres from 'postgres';
import {drizzle} from 'drizzle-orm/postgres-js';
import {pgTable, text} from 'drizzle-orm/pg-core';
import { drizzle } from 'drizzle-orm/postgres-js';
import { pgTable, text } from 'drizzle-orm/pg-core';
// PostgreSQL 데이터베이스 연결 설정
const sql = postgres({
@ -155,24 +155,22 @@ const niceTable = pgTable('nice', {
async function main() {
const baseUrl = 'https://nice.kegorii.workers.dev/get?t=';
const firstArray = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'I', 'J', 'L', 'M', 'N', 'O', 'P', 'Q']
const firstArray = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'I', 'J', 'L', 'M', 'N', 'O', 'P', 'Q'];
for (let i = 0; i < firstArray.length; i++) {
let secondArray = [];
if (i >= 0 && i <= 9) {
secondArray = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
} else {
secondArray = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
}
console.log(secondArray);
for (let x = 0; x < secondArray.length; x++) {
for (let y = 5; y < 20; y++) {
const rtnval = y.toString().padStart(3, '0');
const kiscode = firstArray[i] + secondArray[x] + rtnval;
const url = `${baseUrl}${kiscode}`;
console.log(firstArray[i] + secondArray[x] + rtnval);
try {
const startTime = Date.now(); // 시작 시간 저장
const response = await fetch(url);
if (!response.ok) {
@ -186,12 +184,13 @@ async function main() {
if (insertValues.length > 0) {
await orm.insert(niceTable).values(insertValues);
}
const endTime = Date.now(); // 종료 시간 저장
console.log(`Execution time for kiscode:${kiscode}: ${endTime - startTime} ms`); // 콘솔에 시간 출력
} catch (error) {
console.error(`Error at kiscode:${kiscode}`, error);
}
console.log('ok');
}
}
}