-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
79ee44e
commit aa0de9a
Showing
13 changed files
with
113 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// for debugging purposes only | ||
|
||
import { NextRequest, NextResponse } from "next/server"; | ||
import v8 from "v8"; | ||
import { runInNewContext } from 'vm'; | ||
|
||
|
||
export async function GET(req: NextRequest) { | ||
const searchParams = req.nextUrl.searchParams; | ||
const state = searchParams.get("gc"); | ||
|
||
// enabling trace-gc | ||
if (state === "start") { | ||
v8.setFlagsFromString("--trace-gc"); | ||
|
||
const gc = runInNewContext('gc'); // nocommit | ||
gc(); | ||
|
||
return NextResponse.json({ | ||
result: "gc success", | ||
}); | ||
} | ||
|
||
// dump | ||
if (state == "dump") { | ||
const fileName = v8.writeHeapSnapshot(); | ||
console.log(`Created heapdump file: ${fileName}`); | ||
|
||
return NextResponse.json({ | ||
result: "dump success", | ||
fileName: fileName, | ||
}); | ||
} | ||
|
||
// const searchParams = req.nextUrl.searchParams; | ||
// if (global.gc) { | ||
// global.gc(); | ||
// } else { | ||
// console.log( | ||
// "Garbage collection unavailable. Pass --expose-gc when launching node to enable forced garbage collection." | ||
// ); | ||
// } | ||
const formatMemoryUsage = (data: number) => `${Math.round((data / 1024 / 1024) * 100) / 100} MB`; | ||
|
||
const memoryData = process.memoryUsage(); | ||
|
||
const memoryUsage = { | ||
rss: `${formatMemoryUsage(memoryData.rss)} -> Resident Set Size - total memory allocated for the process execution`, | ||
heapTotal: `${formatMemoryUsage(memoryData.heapTotal)} -> total size of the allocated heap`, | ||
heapUsed: `${formatMemoryUsage(memoryData.heapUsed)} -> actual memory used during the execution`, | ||
external: `${formatMemoryUsage(memoryData.external)} -> V8 external memory`, | ||
arrayBuffers: `${formatMemoryUsage(memoryData.arrayBuffers)} -> array buffers`, | ||
}; | ||
|
||
// const res = NextResponse.json(memoryUsage); | ||
return NextResponse.json(memoryUsage); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
"use client" | ||
|
||
import { cn } from "@/lib/utils"; | ||
import RichText from "../text"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/bin/bash | ||
## This script builds for load testing | ||
# | ||
## Before using, setup a proper url in `target.txt` | ||
## * https://github.com/tsenart/vegeta | ||
# | ||
## Requirements: | ||
## * vegeta | ||
# | ||
## Usage: | ||
# cd ./scripts/load-testing | ||
## chmod +x start_load_testing.sh | ||
## ./start_load_testing/build.sh | ||
## | ||
## Output: | ||
# | ||
BASEDIR=$(dirname $0) | ||
|
||
TARGET="${BASEDIR}/target.txt" | ||
RATE=30 | ||
DURATION="220s" | ||
OUTPUT="${BASEDIR}/output.bin" | ||
WORKERS=10 | ||
MAX_WORKERS=20 | ||
|
||
if [ -f "$OUTPUT" ] ; then | ||
rm "$OUTPUT" | ||
fi | ||
|
||
# start load testing | ||
vegeta attack -targets=$TARGET -rate=$RATE -duration=$DURATION -workers=$WORKERS -max-workers=$MAX_WORKERS > $OUTPUT | ||
|
||
RED='\033[1;31m' | ||
NC='\033[0m' # No Color | ||
|
||
# basic output | ||
echo -e "${RED}Text output:${NC}" | ||
vegeta report $OUTPUT | ||
|
||
echo "" | ||
echo -e "${RED}Histogram output:${NC}" | ||
vegeta report -type='hist[0,10ms,40ms,80ms,200ms,500ms,1000ms]' $OUTPUT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
GET http://127.0.0.1:3000/article/list-blog | ||
# specify trace info | ||
X-Trace-ID: efbdbed17f4c6280e8c8c98d29123b8c |