2002-06-05 11:29:06 +08:00
@ echo off
2004-02-16 21:34:10 +08:00
2007-01-08 03:19:26 +08:00
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
2004-02-16 21:34:10 +08:00
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License.
2006-03-28 09:31:32 +08:00
rem =====================================================
rem Environment variables that can be defined externally:
rem
2018-01-24 04:23:40 +08:00
rem Do not set the variables in this script. Instead put them into a script
rem setenv.bat in JMETER_HOME/bin to keep your customizations separate.
rem
rem DDRAW - (Optional) JVM options to influence usage of direct draw,
rem e.g. '-Dsun.java2d.ddscale=true'
rem
rem JMETER_BIN - JMeter bin directory (must end in \)
rem
rem JMETER_HOME - installation directory. Will be guessed from location of jmeter.bat
rem
rem JM_LAUNCH - java.exe (default) or javaw.exe
rem
rem JM_START - set this to "start" to launch JMeter in a separate window
rem this is used by the jmeterw.cmd script.
rem
rem JVM_ARGS - (Optional) Java options used when starting JMeter, e.g. -Dprop=val
rem Defaults to '-Duser.language="en" -Duser.region="EN"'
rem
rem GC_ALGO - (Optional) JVM garbage collector options
2018-01-27 23:24:32 +08:00
rem Defaults to '-XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem'
2018-01-24 04:23:40 +08:00
rem
rem HEAP - (Optional) JVM memory settings used when starting JMeter
rem Defaults to '-Xms512m -Xmx512m -XX:MaxMetaspaceSize=256m'
2006-03-28 09:31:32 +08:00
rem
rem =====================================================
2014-04-25 05:18:15 +08:00
setlocal
2018-01-24 04:23:40 +08:00
rem Guess JMETER_HOME if not defined
set " CURRENT_DIR= %cd% "
if not " %JMETER_HOME% " == " " goto gotHome
set " JMETER_HOME= %CURRENT_DIR% "
if exist " %JMETER_HOME% \bin\jmeter.bat " goto okHome
cd ..
set " JMETER_HOME= %cd% "
cd " %CURRENT_DIR% "
: gotHome
if exist " %JMETER_HOME% \bin\jmeter.bat " goto okHome
echo The JMETER_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
: okHome
rem Get standard environment variables
if exist " %JMETER_HOME% \bin\setenv.bat " call " %JMETER_HOME% \bin\setenv.bat "
if not defined JVM_ARGS (
rem Set language
rem Default to en_EN
set JVM_ARGS = -Duser.language=" en " -Duser.region=" EN "
)
2014-03-20 15:42:42 +08:00
rem Minimal version to run JMeter
2016-12-28 00:17:11 +08:00
set MINIMAL_VERSION = 1.8.0
2014-03-20 15:42:42 +08:00
2017-10-30 05:33:52 +08:00
rem --add-modules java.activation if JAVA 9
set ADD_MODS =
2014-03-20 15:42:42 +08:00
for /f " tokens=3 " %% g in ( 'java -version 2^>^&1 ^| findstr /i "version"' ) do (
rem @echo Debug Output: %%g
set JAVAVER = %% g
)
if not defined JAVAVER (
@ echo Not able to find Java executable or version. Please check your Java installation.
2014-04-25 04:42:32 +08:00
set ERRORLEVEL = 2
2014-03-20 15:42:42 +08:00
goto pause
)
2017-10-30 05:33:52 +08:00
rem Check if version is from OpenJDK or Oracle Hotspot JVM prior to 9 containing 1.${version}.x
2018-01-27 23:24:32 +08:00
rem JAVAVER will be equal to "9.0.4" (quotes are part of the value) for Oracle Java 9
rem JAVAVER will be equal to "1.8.0_161" (quotes are part of the value) for Oracle Java 8
rem so we extract 2 chars starting from index 1
2018-01-27 22:44:22 +08:00
IF " %JAVAVER:~1,2% " == " 1. " (
2017-10-30 05:33:52 +08:00
set JAVAVER = %JAVAVER:"=%
for /f " delims=. tokens=1-3 " %% v in ( " %JAVAVER% " ) do (
set current_minor = %% w
)
) else (
rem Java 9 at least
set current_minor = 9
set ADD_MODS = --add-modules java.activation
2014-03-20 15:42:42 +08:00
)
2017-10-30 05:33:52 +08:00
2014-03-20 15:42:42 +08:00
for /f " delims=. tokens=1-3 " %% v in ( " %MINIMAL_VERSION% " ) do (
set minimal_minor = %% w
)
if not defined current_minor (
@ echo Not able to find Java executable or version. Please check your Java installation.
2014-04-25 04:42:32 +08:00
set ERRORLEVEL = 2
2014-03-20 15:42:42 +08:00
goto pause
)
rem @echo Debug: CURRENT=%current_minor% - MINIMAL=%minimal_minor%
if %current_minor% LSS %minimal_minor% (
2014-04-25 04:42:32 +08:00
@ echo Error: Java version -- %JAVAVER% -- is too low to run JMeter. Needs a Java version greater than or equal to %MINIMAL_VERSION%
set ERRORLEVEL = 3
2014-03-20 15:42:42 +08:00
goto pause
)
2005-03-18 23:27:20 +08:00
if .%JM_LAUNCH% == . set JM_LAUNCH = java.exe
if exist jmeter.bat goto winNT1
2006-04-29 23:11:54 +08:00
if .%JMETER_BIN% == . set JMETER_BIN = %~dp0
2006-04-08 08:26:05 +08:00
2005-03-18 23:27:20 +08:00
: winNT1
2002-06-05 11:29:06 +08:00
rem On NT/2K grab all arguments at once
set JMETER_CMD_LINE_ARGS = %*
2008-05-24 20:29:07 +08:00
rem The following link describes the -XX options:
2017-01-17 05:27:21 +08:00
rem http://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html
2008-05-24 20:29:07 +08:00
2018-01-24 04:23:40 +08:00
if not defined HEAP (
rem See the unix startup file for the rationale of the following parameters,
rem including some tuning recommendations
set HEAP = -Xms512m -Xmx512m -XX:MaxMetaspaceSize=256m
)
2017-01-17 05:27:21 +08:00
2017-10-30 06:34:35 +08:00
rem Uncomment this to generate GC verbose file with Java prior to 9
2017-11-24 21:31:41 +08:00
rem set VERBOSE_GC=-verbose:gc -Xloggc:gc_jmeter_%%p.log -XX:+PrintGCDetails -XX:+PrintGCCause -XX:+PrintTenuringDistribution -XX:+PrintHeapAtGC -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCDateStamps -XX:+PrintAdaptiveSizePolicy
2017-01-17 05:27:21 +08:00
2017-10-30 06:34:35 +08:00
rem Uncomment this to generate GC verbose file with Java 9 and above
rem set VERBOSE_GC=-Xlog:gc*,gc+age=trace,gc+heap=debug:file=gc_jmeter_%%p.log
2018-01-24 04:23:40 +08:00
if not defined GC_ALGO (
2018-01-27 23:24:32 +08:00
set GC_ALGO = -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:G1ReservePercent=20 -XX:+ParallelRefProcEnabled -XX:+PerfDisableSharedMem
2018-01-24 04:23:40 +08:00
)
2014-03-20 15:42:42 +08:00
2017-01-25 04:17:10 +08:00
set SYSTEM_PROPS = -Djava.security.egd=file:/dev/urandom
2017-10-30 06:46:51 +08:00
2008-11-08 22:13:44 +08:00
rem Always dump on OOM (does not cost anything unless triggered)
set DUMP = -XX:+HeapDumpOnOutOfMemoryError
2003-11-28 20:18:05 +08:00
2017-10-30 06:46:51 +08:00
rem Uncomment this if you run JMeter in DOCKER (need Java SE 8u131 or JDK 9)
rem see https://blogs.oracle.com/java-platform-group/java-se-support-for-docker-cpu-and-memory-limits
rem set RUN_IN_DOCKER=-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap
2005-03-18 23:27:20 +08:00
rem Additional settings that might help improve GUI performance on some platforms
2017-01-17 05:27:21 +08:00
rem See: http://www.oracle.com/technetwork/java/perf-graphics-135933.html
2005-03-18 23:27:20 +08:00
2018-01-24 04:23:40 +08:00
if not defined DDRAW (
set DDRAW =
rem Setting this flag to true turns off DirectDraw usage, which sometimes helps to get rid of a lot of rendering problems on Win32.
rem set DDRAW=%DDRAW% -Dsun.java2d.noddraw=true
2005-03-18 23:27:20 +08:00
2018-01-24 04:23:40 +08:00
rem Setting this flag to false turns off DirectDraw offscreen surfaces acceleration by forcing all createVolatileImage calls to become createImage calls, and disables hidden acceleration performed on surfaces created with createImage .
rem set DDRAW=%DDRAW% -Dsun.java2d.ddoffscreen=false
2005-03-18 23:27:20 +08:00
2018-01-24 04:23:40 +08:00
rem Setting this flag to true enables hardware-accelerated scaling.
rem set DDRAW=%DDRAW% -Dsun.java2d.ddscale=true
)
2005-03-18 23:27:20 +08:00
2008-05-24 20:29:07 +08:00
rem Server mode
2017-10-30 06:55:56 +08:00
set SERVER = -server
2005-03-18 23:27:20 +08:00
rem Collect the settings defined above
2017-10-30 14:34:41 +08:00
set ARGS = %SERVER% %DUMP% %HEAP% %VERBOSE_GC% %GC_ALGO% %DDRAW% %SYSTEM_PROPS% %RUN_IN_DOCKER%
2017-01-25 05:09:46 +08:00
2018-01-27 22:05:11 +08:00
%JM_START% %JM_LAUNCH% %ADD_MODS% %ARGS% %JVM_ARGS% -jar " %JMETER_BIN% ApacheJMeter.jar " %JMETER_CMD_LINE_ARGS%
2007-10-16 22:39:22 +08:00
2007-10-18 03:27:05 +08:00
rem If the errorlevel is not zero, then display it and pause
2007-10-16 22:39:22 +08:00
2007-10-18 03:27:05 +08:00
if NOT errorlevel 0 goto pause
if errorlevel 1 goto pause
goto end
: pause
echo errorlevel=%ERRORLEVEL%
pause
: end
2014-03-20 15:42:42 +08:00