first commit

This commit is contained in:
Muhamad Ibnu Fadhil 2025-11-17 20:11:26 +07:00
commit 27e101260c
6 changed files with 547 additions and 0 deletions

40
throughput/jmeter.log Normal file
View file

@ -0,0 +1,40 @@
2025-11-17 17:31:17,310 INFO o.a.j.u.JMeterUtils: Setting Locale to en_EN
2025-11-17 17:31:17,327 INFO o.a.j.JMeter: Loading user properties from: /opt/apache-jmeter-5.6.3/bin/user.properties
2025-11-17 17:31:17,327 INFO o.a.j.JMeter: Loading system properties from: /opt/apache-jmeter-5.6.3/bin/system.properties
2025-11-17 17:31:17,332 INFO o.a.j.JMeter: Copyright (c) 1998-2024 The Apache Software Foundation
2025-11-17 17:31:17,332 INFO o.a.j.JMeter: Version 5.6.3
2025-11-17 17:31:17,332 INFO o.a.j.JMeter: java.version=21.0.8
2025-11-17 17:31:17,332 INFO o.a.j.JMeter: java.vm.name=OpenJDK 64-Bit Server VM
2025-11-17 17:31:17,332 INFO o.a.j.JMeter: os.name=Linux
2025-11-17 17:31:17,332 INFO o.a.j.JMeter: os.arch=amd64
2025-11-17 17:31:17,332 INFO o.a.j.JMeter: os.version=6.14.0-35-generic
2025-11-17 17:31:17,332 INFO o.a.j.JMeter: file.encoding=UTF-8
2025-11-17 17:31:17,332 INFO o.a.j.JMeter: java.awt.headless=null
2025-11-17 17:31:17,332 INFO o.a.j.JMeter: Max memory =1073741824
2025-11-17 17:31:17,332 INFO o.a.j.JMeter: Available Processors =8
2025-11-17 17:31:17,340 INFO o.a.j.JMeter: Default Locale=English (EN)
2025-11-17 17:31:17,341 INFO o.a.j.JMeter: JMeter Locale=English (EN)
2025-11-17 17:31:17,341 INFO o.a.j.JMeter: JMeterHome=/opt/apache-jmeter-5.6.3
2025-11-17 17:31:17,341 INFO o.a.j.JMeter: user.dir =/home/ibnufadhil/Documents/projects/benchmark/throughput
2025-11-17 17:31:17,341 INFO o.a.j.JMeter: PWD =/home/ibnufadhil/Documents/projects/benchmark/throughput
2025-11-17 17:31:17,391 INFO o.a.j.JMeter: IP: 10.250.7.97 Name: SE-146 FullName: SE-146
2025-11-17 17:31:17,398 INFO o.a.j.JMeter: Loaded icon properties from org/apache/jmeter/images/icon.properties
2025-11-17 17:31:17,543 INFO o.a.j.JMeterGuiLauncher: Setting LAF to: com.github.weisj.darklaf.DarkLaf:com.github.weisj.darklaf.theme.DarculaTheme
2025-11-17 17:31:25,059 INFO o.a.j.s.FileServer: Default base='/home/ibnufadhil/Documents/projects/benchmark/throughput'
2025-11-17 17:31:25,061 INFO o.a.j.g.a.Load: Loading file: /home/ibnufadhil/Documents/projects/benchmark/throughput/stitcher-benchmark.jmx
2025-11-17 17:31:25,061 INFO o.a.j.s.FileServer: Set new base='/home/ibnufadhil/Documents/projects/benchmark/throughput'
2025-11-17 17:31:25,209 INFO o.a.j.s.SaveService: Testplan (JMX) version: 2.2. Testlog (JTL) version: 2.2
2025-11-17 17:31:25,236 INFO o.a.j.s.SaveService: Using SaveService properties version 5.0
2025-11-17 17:31:25,238 INFO o.a.j.s.SaveService: Using SaveService properties file encoding UTF-8
2025-11-17 17:31:25,240 INFO o.a.j.s.SaveService: Loading file: /home/ibnufadhil/Documents/projects/benchmark/throughput/stitcher-benchmark.jmx
2025-11-17 17:31:25,259 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/html is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2025-11-17 17:31:25,259 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xhtml+xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2025-11-17 17:31:25,260 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for application/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2025-11-17 17:31:25,260 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/xml is org.apache.jmeter.protocol.http.parser.LagartoBasedHtmlParser
2025-11-17 17:31:25,260 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/vnd.wap.wml is org.apache.jmeter.protocol.http.parser.RegexpHTMLParser
2025-11-17 17:31:25,260 INFO o.a.j.p.h.s.HTTPSamplerBase: Parser for text/css is org.apache.jmeter.protocol.http.parser.CssParser
2025-11-17 17:31:25,601 INFO o.a.j.s.SampleResult: Note: Sample TimeStamps are START times
2025-11-17 17:31:25,601 INFO o.a.j.s.SampleResult: sampleresult.default.encoding is set to UTF-8
2025-11-17 17:31:25,601 INFO o.a.j.s.SampleResult: sampleresult.useNanoTime=true
2025-11-17 17:31:25,601 INFO o.a.j.s.SampleResult: sampleresult.nanoThreadSleep=5000
2025-11-17 17:31:25,712 INFO o.a.j.s.FileServer: Set new base='/home/ibnufadhil/Documents/projects/benchmark/throughput'

114
throughput/request.sh Executable file
View file

@ -0,0 +1,114 @@
#!/bin/bash
JMX_FILE="./stitcher-benchmark.jmx"
JMETER_CMD="jmeter"
DEFAULT_THREADS=10
DEFAULT_LOOPS=10
APP_NAME=""
TARGET_URL=""
THREADS=$DEFAULT_THREADS
LOOPS=$DEFAULT_LOOPS
show_help() {
echo "Usage: $0 -u <AppName> -H <TargetURL> [-t <Threads>] [-l <Loops>]"
echo ""
echo "Runs a JMeter benchmark test with specified parameters."
echo ""
echo "Required Flags:"
echo " -o, --output The name of the app or user for organizing results."
echo " -H, --host The target URL or IP address for the test (e.g., 10.250.22.29)."
echo ""
echo "Optional Flags:"
echo " -t, --threads Number of concurrent threads (users). Default: ${DEFAULT_THREADS}."
echo " -l, --loops Number of loops each thread will execute. Default: ${DEFAULT_LOOPS}."
echo " -h, --help Display this help message and exit."
}
while [[ $# -gt 0 ]]; do
key="$1"
case $key in
-o|--output)
APP_NAME="$2"
shift
shift
;;
-H|--host)
TARGET_URL="$2"
shift
shift
;;
-t|--threads)
THREADS="$2"
shift
shift
;;
-l|--loops)
LOOPS="$2"
shift
shift
;;
-h|--help)
show_help
exit 0
;;
*)
echo "Unknown option: $1"
show_help
exit 1
;;
esac
done
if [ -z "$APP_NAME" ] || [ -z "$TARGET_URL" ]; then
echo "ERROR: Missing required arguments."
echo ""
show_help
exit 1
fi
# --- Define Output Structure ---
MAIN_OUTPUT_DIR="./${APP_NAME}"
RESULT_CSV="${MAIN_OUTPUT_DIR}/${APP_NAME}_benchmark.csv"
RESULT_DASHBOARD="${MAIN_OUTPUT_DIR}/${APP_NAME}_dashboard"
JMETER_LOG_FILE="${MAIN_OUTPUT_DIR}/${APP_NAME}_jmeter.log"
echo "--- Preparing for test run: '$APP_NAME' ---"
mkdir -p "$MAIN_OUTPUT_DIR"
echo "Output will be saved in: $MAIN_OUTPUT_DIR"
echo "Cleaning up previous results..."
rm -f "$RESULT_CSV"
rm -rf "$RESULT_DASHBOARD"
rm -f "$JMETER_LOG_FILE"
echo "Cleanup complete."
echo ""
echo "--- Starting JMeter Benchmark ---"
echo " Target Host: $TARGET_URL"
echo " Concurrency: $THREADS threads"
echo " Iterations: $LOOPS loops per thread"
echo " Total Requests: $((THREADS * LOOPS))"
echo "---------------------------------"
$JMETER_CMD -n \
-t "$JMX_FILE" \
-l "$RESULT_CSV" \
-e -o "$RESULT_DASHBOARD" \
-j "$JMETER_LOG_FILE" \
-Jthreads="$THREADS" \
-Jloops="$LOOPS" \
-Jurl="$TARGET_URL"
if [ $? -eq 0 ]; then
echo ""
echo "--- Benchmark Finished Successfully ---"
echo "The HTML report is available here:"
echo "file://$PWD/${RESULT_DASHBOARD}/index.html"
echo "---------------------------------------"
else
echo ""
echo "--- JMeter Finished with an Error ---"
echo "Check the log file for details: ${JMETER_LOG_FILE}"
echo "-------------------------------------"
fi

View file

@ -0,0 +1,179 @@
<?xml version="1.0" encoding="UTF-8"?>
<jmeterTestPlan version="1.2" properties="5.0" jmeter="5.6.3">
<hashTree>
<TestPlan guiclass="TestPlanGui" testclass="TestPlan" testname="stitcher-benchmark">
<elementProp name="TestPlan.user_defined_variables" elementType="Arguments" guiclass="ArgumentsPanel" testclass="Arguments" testname="User Defined Variables">
<collectionProp name="Arguments.arguments"/>
</elementProp>
</TestPlan>
<hashTree>
<ThreadGroup guiclass="ThreadGroupGui" testclass="ThreadGroup" testname="Thread Group">
<stringProp name="ThreadGroup.num_threads">${__P(threads, 10)}</stringProp>
<intProp name="ThreadGroup.ramp_time">1</intProp>
<boolProp name="ThreadGroup.same_user_on_next_iteration">true</boolProp>
<stringProp name="ThreadGroup.on_sample_error">continue</stringProp>
<elementProp name="ThreadGroup.main_controller" elementType="LoopController" guiclass="LoopControlPanel" testclass="LoopController" testname="Loop Controller">
<stringProp name="LoopController.loops">${__P(loops, 50)}</stringProp>
<boolProp name="LoopController.continue_forever">false</boolProp>
</elementProp>
</ThreadGroup>
<hashTree>
<HTTPSamplerProxy guiclass="HttpTestSampleGui" testclass="HTTPSamplerProxy" testname="HTTP Request">
<stringProp name="HTTPSampler.domain">${__P(url, stitchaton.local)}</stringProp>
<stringProp name="HTTPSampler.port">5000</stringProp>
<stringProp name="HTTPSampler.protocol">http</stringProp>
<stringProp name="HTTPSampler.path">/api/image/generate</stringProp>
<boolProp name="HTTPSampler.follow_redirects">true</boolProp>
<stringProp name="HTTPSampler.method">POST</stringProp>
<boolProp name="HTTPSampler.use_keepalive">true</boolProp>
<boolProp name="HTTPSampler.postBodyRaw">true</boolProp>
<elementProp name="HTTPsampler.Arguments" elementType="Arguments">
<collectionProp name="Arguments.arguments">
<elementProp name="" elementType="HTTPArgument">
<boolProp name="HTTPArgument.always_encode">false</boolProp>
<stringProp name="Argument.value">{&#xd;
&quot;canvas_rect&quot;: &quot;${canvasRect}&quot;,&#xd;
&quot;crop_offset&quot;: [0.25, 0.25],&#xd;
&quot;crop_size&quot;: [0.5, 0.5],&#xd;
&quot;output_scale&quot;: 0.5&#xd;
}</stringProp>
<stringProp name="Argument.metadata">=</stringProp>
</elementProp>
</collectionProp>
</elementProp>
</HTTPSamplerProxy>
<hashTree>
<JSR223PreProcessor guiclass="TestBeanGUI" testclass="JSR223PreProcessor" testname="JSR223 PreProcessor">
<stringProp name="cacheKey">true</stringProp>
<stringProp name="filename"></stringProp>
<stringProp name="parameters"></stringProp>
<stringProp name="script">// Function to convert a numeric index (1-31) to the SBS Plate Row format (A-AE)
String indexToRow(int num) {
if (num &lt;= 0) return &quot;&quot;;
if (num &lt;= 26) {
// A-Z is ASCII 65-90. &apos;A&apos; is char 65. So (num - 1) + 65.
return (char)(num + 64) as String;
} else {
// For AA-AE, the first char is &apos;A&apos;.
// 27 -&gt; AA, 28 -&gt; AB, etc.
// The second char is (num - 27) + 65 -&gt; &apos;A&apos;, &apos;B&apos;, etc.
return &quot;A&quot; + (char)(num - 26 + 64) as String;
}
}
// Define the maximum starting indices for a 2x2 grid
// Max row is AE (31), so max starting row is AD (30)
// Max col is 55, so max starting col is 54
int maxStartRowIndex = 30;
int maxStartCol = 54;
// Generate random starting coordinates
// nextInt(bound) generates 0 to bound-1, so add 1
int randomRowStartIndex = new Random().nextInt(maxStartRowIndex) + 1;
int randomColStart = new Random().nextInt(maxStartCol) + 1;
// Calculate the end coordinates for the 2x2 grid
String rowStart = indexToRow(randomRowStartIndex);
String rowEnd = indexToRow(randomRowStartIndex + 1);
int colEnd = randomColStart + 1;
// Construct the final canvas_rect string
String canvasRectValue = &quot;${rowStart}${randomColStart}:${rowEnd}${colEnd}&quot;;
// Store the generated string in a JMeter variable named &quot;canvasRect&quot;
// This makes it available to the HTTP Request sampler
vars.put(&quot;canvasRect&quot;, canvasRectValue);
// Optional: Log the generated value to see it in the JMeter log (for debugging)
log.info(&quot;Generated canvas_rect: &quot; + canvasRectValue);</stringProp>
<stringProp name="scriptLanguage">groovy</stringProp>
</JSR223PreProcessor>
<hashTree/>
<HeaderManager guiclass="HeaderPanel" testclass="HeaderManager" testname="HTTP Header Manager">
<collectionProp name="HeaderManager.headers">
<elementProp name="" elementType="Header">
<stringProp name="Header.name">Content-Type</stringProp>
<stringProp name="Header.value">application/json</stringProp>
</elementProp>
</collectionProp>
</HeaderManager>
<hashTree/>
</hashTree>
<ResultCollector guiclass="SummaryReport" testclass="ResultCollector" testname="Summary Report">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<url>true</url>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename">/home/ibnufadhil/Documents/projects/benchmark/result.csv</stringProp>
</ResultCollector>
<hashTree/>
<ResultCollector guiclass="ViewResultsFullVisualizer" testclass="ResultCollector" testname="View Results Tree">
<boolProp name="ResultCollector.error_logging">false</boolProp>
<objProp>
<name>saveConfig</name>
<value class="SampleSaveConfiguration">
<time>true</time>
<latency>true</latency>
<timestamp>true</timestamp>
<success>true</success>
<label>true</label>
<code>true</code>
<message>true</message>
<threadName>true</threadName>
<dataType>true</dataType>
<encoding>false</encoding>
<assertions>true</assertions>
<subresults>true</subresults>
<responseData>false</responseData>
<samplerData>false</samplerData>
<xml>false</xml>
<fieldNames>true</fieldNames>
<responseHeaders>false</responseHeaders>
<requestHeaders>false</requestHeaders>
<responseDataOnError>false</responseDataOnError>
<saveAssertionResultsFailureMessage>true</saveAssertionResultsFailureMessage>
<assertionsResultsToSave>0</assertionsResultsToSave>
<bytes>true</bytes>
<sentBytes>true</sentBytes>
<url>true</url>
<threadCounts>true</threadCounts>
<idleTime>true</idleTime>
<connectTime>true</connectTime>
</value>
</objProp>
<stringProp name="filename"></stringProp>
</ResultCollector>
<hashTree/>
</hashTree>
</hashTree>
</hashTree>
</jmeterTestPlan>