圌ãªãã§ã¯ã©ãã§ããïŒ
ååãšããŠãããŒãã¹ããŒã·ã§ã³èªäœã®ããã©ãŒãã³ã¹ã«é¢ããŠæé«ã®çµæãåŸãã«ã¯ãJavaãªã¯ãšã¹ããå®è£ ããããç¬èªã®ãµã³ãã©ãŒãäœæããããšãæãå¹æçã§ãã ããããå人çã«ãç§ã¯ãã®ãœãªã¥ãŒã·ã§ã³ã奜ãã§ã¯ãããŸããïŒ
- ãœãªã¥ãŒã·ã§ã³ã®éçºã«ããã人件費ã®å¢å ã
- ãœãªã¥ãŒã·ã§ã³ã®éééçãªãµããŒãïŒã³ãŒãã¯å¥ã®å Žæã«ãããè¿œå ã®ã¢ã¯ã·ã§ã³ã䜿çšããŠåã³ã³ãã€ã«ããå¿ èŠããããŸãïŒã
- JMeterãæäŸããå¯èœæ§ã®ããããŒãã¹ã®æ倱ïŒããšãã°ãã³ãŒãã§DBMSãžã®ãªã¯ãšã¹ããå®è¡ãã次ã«HTTPãªã¯ãšã¹ããå®è¡ããå Žåããããã¯åèšã§ã¯ãªãåå¥ã«è¡šç€ºãããŸãïŒã
ã ããç§ã¯ãã€ããã®ãããªæ±ºå®ãé¿ããããšããŸããïŒãããŠä»ã®ãšããé¿ããŸããïŒïŒã å人çã«ã¯ãã³ãŒãããã¹ãèšç»èªäœã«å«ãŸããŠãããšãã«æ°ã«å ¥ã£ãŠãããJMeterã䜿çšããŠãã®ã³ãŒããå®è¡ããã®ã«ãããæéã远跡ã§ããŸãã ãã®æå³ã§ãBeanShellãµã³ãã©ãŒã¢ãããŒãèªäœã¯éåžžã«äŸ¿å©ã§ãããå®è£ ã®ã¿ãæªãã§ãã çç±ã説æããŸãã
æªãBeanShellãµã³ãã©ãŒãšã¯
BeanShell Samplerã®ã³ãŒãæ¿å ¥ã䜿çšããŠãé«åºŠã«ããŒãããããã¹ãèšç»ãéçºããŸããã éçºæ®µéã§ã¯ãã¹ãŠé 調ã§ããããè² è·ãã¹ãã®è©Šçšãéå§ãããšãéåžžã«äžå¿«ãªåäœãçºçããŸããã ç¹å®ã®æ°ã®ã¹ã¬ããã§ã¯ããã¹ãŠãæ£åžžã«æ©èœããŸããã ããããã¹ã¬ããæ°ã®å¢å ã«äŒŽããããã€ãã®äžååããå§ãŸããŸããã ãã®ãã¹ãã§ã¯ãã¿ãŒã²ããã®è² è·åŒ·åºŠãå€§å¹ ã«äžè¶³ããŠãããã¬ããŒãã§ã¯ãåã ã®BeanShellãµã³ãã«ã®åŠçæéãæ°åç§ã«éããããšã瀺ãããŸããã ããã«ãBeanShellãµã³ãã©ãŒã¯éåžžã«å°ãªããã¹ã¬ããã°ã«ãŒãããšã«1ã€ãŸãã¯2ã€ã§ãããããã§è€éãªããšãèµ·ãã£ããšã¯èšããŸããã ããŒãã¹ããŒã·ã§ã³èªäœã®ããã©ãŒãã³ã¹ãã©ã¡ãŒã¿ãŒã調ã¹ãŠãåé¡ã¯èŠã€ãããŸããã§ãããCPUè² è·ã¯20ã30ïŒ ã§ãJMeterããã»ã¹ã«ååãªã¡ã¢ãªããããã¬ããŒãžã³ã¬ã¯ã¿ãŒã¯ã¿ã€ã ãªãŒã«ã¯ãªãŒã³ã¢ããããŸããã åé¡ãJMeterã®ããã°ã©ã ã³ãŒãèªäœãŸãã¯BeanShellã€ã³ã¿ãŒããªã¿ãŒã®å®è£ ã«ããããšã¯æããã§ãã Daw Reset bsh.Interpreterã§éãã§ãäœãåŸãããŸããã ããã ãã§ã¯ãããŸãããããå Žæã§ã¯ãã¡ã¢ãªãªãŒããŒã©ã³ããªãããã«ã€ã³ã¹ããŒã«ããæ¹ãè¯ããšæžããŠãããå¥ã®å Žæã§ã¯ãããã©ãŒãã³ã¹äžã®çç±ã§åé€ããæ¹ãè¯ããšæžããŠããŸãã
ãã®ãããªåé¡ã«é¢ããã¡ãã»ãŒãžã¯ãJMeterãã©ãŒã©ã ã§æã èŠãããApache JMeter Userã¡ãŒãªã³ã°ãªã¹ãã«èŒã£ãŠããŸãã ååãäžéšã®ãã¹ãã®åäœã«ã€ããŠäžæºãè¿°ã¹ãŠããŸããããåé¡ã¯ããŒã«èªäœã«èµ·å ããåŸåããããŸããã
ã©ããã
JMeterã«ã¯ãJSR223ãµã³ãã©ãŒãšåŒã°ããéåžžã«ãã䌌ããµã³ãã©ãŒããããŸãã ãµã³ãã©ãŒã ãã§ãªãããã¡ããªãŒå šäœïŒãµã³ãã©ãŒãã¿ã€ããŒãããªããã»ããµãŒãšãã¹ãããã»ããµãŒãã¢ãµãŒã·ã§ã³ãã¿ã€ããŒããªã¹ããŒã ãã®ãµã³ãã©ãŒã¯ããã®ãµã³ãã©ãŒãå€§å¹ ãªããã©ãŒãã³ã¹ã®æ¹åãéæãããšããéåžžã«å¿åŒ·ãèšèã§å§ãŸããŸãã ãããã泚ææ·±ãèªè ã¯ããã«åæºããŸãããã®å¹æãéæããã«ã¯ãã³ã³ãã€ã«ããµããŒãããã¹ã¯ãªãããšã³ãžã³ãéžæããå¿ èŠããããŸãã ãã®ããè¿ãã§ãJavaãšã³ãžã³ãããã§ã¯ãªãããšã瀺ãããŠããŸãã
Javaã«ã€ããŠã¯ãããã«èšããŸããBeanShellãšåããšã³ãžã³ã§å®è£ ãããŠããŸãã ããã¯ãå®è¡å¯èœã³ãŒãã§ãšã©ãŒãçºçãããããšã§ç°¡åã«ç¢ºèªã§ããŸãã ãã°ã®äŸå€ã¹ã¿ãã¯ã§ãbshã€ã³ã¿ãŒããªã¿ãŒããããšããã®äž¡æ¹ã§åŒã³åºãããŠããããšãããããŸãã ãããã£ãŠãJSR223 / javaãšBeanShell Samplerã®éã«ãŸã£ããéãã¯ãããŸããã ä»ã®ãšã³ãžã³ã«ã€ããŠã¯äœãèšãããŠããŸãããããããããã¹ãŠè§£éãããŸãã ãããã£ãŠãæšæºã®JMeterããã±ãŒãžã«ã¯ãã³ã³ãã€ã«ã«ãã£ãŠå©çãåŸãããšãã§ãããšã³ãžã³ã¯ãããŸããã
ããã¥ã¡ã³ãã§èšåãããŠããå¯äžã®ã³ã³ãã€ã«æžã¿ã¹ã¯ãªãããšã³ãžã³ã¯Groovyã§ãã JSR223ããµããŒãããä»ã®ãšã³ãžã³ããããŸãã ç§ã¯Scalaãè©ŠããŠã¿ãŸãããããã®æãããã«ãã£ãããšåããŠããããæãããã®ãããã¯ãããè¯ãæãŸã§æ®ããŸããã ïŒæ³šïŒããã§ã®ãã€ã³ãã¯ããããScalaã§ã¯ãªããJSR 223æšæºã®å®è£ ãšCompilableã€ã³ã¿ãŒãã§ãŒã¹ã®å®è£ ã§ããïŒ
GroovyãµããŒããæå¹ã«ããã«ã¯ããããžã§ã¯ãã®Webãµã€ããŸãã¯ãã¡ããããã€ããªã®ææ°ããŒãžã§ã³ãããŠã³ããŒãããå¿ èŠããããŸã ã ã¢ãŒã«ã€ãããå¿ èŠãªãã¡ã€ã«ã¯ãembeddable \ groovy-all- {version} .jarã®1ã€ã ãã§ãã Zhimetrã®libãã©ã«ããŒã«è§£åããŸãã ããã°ã©ã ãåèµ·åãããšãå©çšå¯èœãªJSR223èšèªã®ãªã¹ãã«Groovyã衚瀺ãããŸãã
JSR223 + Groovyã§ã®ãã¹ãèšç»ã®ãã¹ãŠã®BeanShellãµã³ãã©ãŒãäœãçŽããåŸãå¥è·¡ãèµ·ãããŸããïŒãã¹ãŠãæ£åžžã«ïŒæ£åžžã«ããŸãã¯å°ãªããšãããã°ã©ãã³ã°ãããšããã«ïŒåäœãå§ãããã¬ãŒããªãã§CPUè² è·ãããã«äœããªããŸããã JSR223ãµã³ãã©ãŒã®å¿çæéã¯æ¡éãã«çããªãããã¹ãã¯å¿ èŠãªè² è·ã«éããŸããã
Groovyããã©ãŒãã³ã¹
å§ãã«æ»ã£ãå Žå-è¿œå ã®ãœãããŠã§ã¢ããžãã¯ãå®è£ ããããŸããŸãªæ¹æ³-Groovyã䜿çšãããœãªã¥ãŒã·ã§ã³ã¯ãå®éã«ããŒã»ã³ããŒãžãçµãå¿ èŠãããå Žåãé€ããã»ãšãã©ãã¹ãŠã®å Žåã«ååãªã¯ãã§ãã Groovyã¹ã¯ãªããã¯ãéåžžã®Javaãã€ãã³ãŒãã«ã³ã³ãã€ã«ããããã€ãã£ãJavaã³ãŒãã§ãããã®ããã«åã¹ã¬ããã®ã³ã³ããã¹ãã§å®è¡ãããŸãïŒãã ããç¬èªã®ã³ã³ãã€ã©ãŒãããããšã³ãžã³ãåŒã³åºãããã®ãªãŒããŒãããããŸã ããããšã«æ³šæããŠãã ããïŒã Blazemeterã®é¢ä¿è ã¯ãããŸããŸãªå®è£ ãªãã·ã§ã³ã®é床ãæ¯èŒããGroovyã³ãŒãã®é床ã¯pure Javaã®ã³ãŒãã«æ¯ã¹ãŠãããã«å£ããšããçµè«ã«éããŸããã
ç§ãå°ãå®éšãããŸããã æŽæ°æŒç®ã§äººå·¥çãªèšç®ãå®è¡ããå°ããªãã©ã°ã¡ã³ããäœæããŸããã
int i; int s = Integer.parseInt(Parameters); for (i = 1; i < 10000; i++) { s += i * (i % 2 * 2 - 1); } log.warn(s.toString());
å ¥åããŒã¿ïŒãã©ã¡ãŒã¿ãŒïŒãšãã°ãžã®äŸåæ§ã¯ã念ã®ããã«è¿œå ãããŸãããããã¯ãå®è¡ãå®å šã«é€å€ããããçµæããã£ãã·ã¥ããããããããªãããŒãªã³ã³ãã€ã©ãŒãšã€ã³ã¿ãŒããªã¿ãŒãã³ãŒããæé©åããã®ãé²ãããã§ãã ããã«ããã©ã¡ãŒã¿ããŠããŒã¯ã§ããã 1000å埩ã®100ã¹ã¬ãããåããCore i7ãæèŒããã©ãããããã§ã¯ãåçµæã¯æ¬¡ã®ãšããã§ããã
å®è£ | ã¹ã«ãŒããã
|
---|---|
Beanshellãµã³ãã©ãŒ | ã20 /ç§
|
JSR223 +ïŒjava | beanshell | bshïŒ | ã20 /ç§
|
JSR223 + Groovy | ã13800 /ç§
|
Groovyã®ã®ã£ããã¯éåžžã«å€§ãããããä¿¡ããããšããå°é£ã§ããããã°ããå€æãããšããã¹ãŠãæ£åžžã«æ©èœããŠããŸããã
Groovyã®ãµãã»ãããšããŠã®Java
Groovyã®å€§ããªå©ç¹ã¯ã95ïŒ ã®ã±ãŒã¹ã§ãä»»æã®Javaã³ãŒããæå¹ãªGroovyã³ãŒãã§ããããšã§ãã BeanShellæ§æã§ãããçŸåšã®Javaæšæºããããã«é¢ããŠããŸãïŒããšãã°ãBeanShellã§ã¯ãä»»æã®æ°ã®åŒæ°ã䜿çšããŠé¢æ°ãåŒã³åºãå Žåã¯ãå€æŽããå¿ èŠããããŸãïŒã çŸæç¹ã§ãã¹ãŠã®å¯èœæ§ãåŠç¿ããããšã«èå³ããªãå Žåã¯ããã®å¿ èŠã¯ãããŸããã äžæ¹ãããªããããããã¹ã¿ãŒããã°ãããªãã¯ç¢ºå®ã«ããªãã®å¹æãé«ããããšãã§ããã§ãããã
bsh.shared
BeanShellã§ã°ããŒãã«åå空ébsh.sharedã䜿çšããå Žåãå°ããªåŸ ã¡äŒãããããŸããGroovyã«ã¯ãã®çš®ã®ãã®ã¯äœããããŸããã 幞ããªããšã«ããã®åé¡ã¯èªåã§ç°¡åã«è§£æ±ºã§ããŸãã ãã®ããã«ã10è¡ã®ã³ãŒããèšè¿°ãããŠããŸãã
import java.util.concurrent.ConcurrentHashMap; public class SharedHashMap { private static final ConcurrentHashMap instance = new ConcurrentHashMap(); public static ConcurrentHashMap GetInstance() { return instance; } }
å®éãããã¯ã·ã³ã°ã«ãã³ã§ãããåžžã«ïŒåã¹ã¬ããã«å¯ŸããŠïŒåããªããžã§ã¯ããè¿ããŸãã ããã«ãjarã«åéãããZhimetrã®libãã©ã«ããŒã«é 眮ãããŸãã ã¯ã©ã¹ã¯ã°ããŒãã«åå空éã§å®£èšãããŠããã®ã§ïŒãããããã¯éé£ãããŸãïŒãGroovyã³ãŒãã§ã¯ã€ã³ããŒãããã«ãSharedHashMapã䜿çšããŠããã«äœãã眮ãããšãã§ããŸãã
// hash map. sharedHashMap = SharedHashMap.GetInstance() // -. sharedHashMap.put('Counter', new java.util.concurrent.atomic.AtomicInteger())
ããªããæŸãå¿ èŠããããšããåæ§ã«ïŒ
sharedHashMap = SharedHashMap.GetInstance() // * counter = sharedHashMap.get('Counter') counter.incrementAndGet() //..
* Groovyã¯ãã»ãã³ãã³ãšåæ§ã«å€æ°ã®åã宣èšããå¿ èŠã¯ãããŸããã
BeanShell Samplerã䜿çšãã移è¡
ãã§ã«å€ãã®BeanShellãµã³ãã©ãŒãå«ãŸããŠãããã¹ãèšç»ãæ¢ã«ãããåé¡ãããããã«ãã®èšäºãèŠã€ãããšããŸãã Groovyã«åãæ¿ããŸãã Groovyæ¥ç¶ã¯äžèšã§èª¬æãããŠããã5å以å ã«å®äºããŸãã
ãŸããJSR223ãµã³ãã©ãŒãäœæããBeanShellããã³ãŒãã転éããŸãã ã³ãŒããçµ±åãã[ãã¡ã€ã«å]ãã£ãŒã«ãã§æå®ããããšã§å¥ã®ãã¡ã€ã«ã§éžæã§ããå Žåãç掻ãå€§å¹ ã«ç°¡çŽ åã§ããŸãã 次ã«ãã³ããŒ/貌ãä»ãã䜿çšããŠãJSR223ãµã³ãã©ãŒãé©åãªå Žæã«è²Œãä»ããã ãã§ãã ããã§ãªãå Žåã¯ãããããã®å Žåã«BeanShellããã³ãŒããã³ããŒããŸãã
ãã£ãã·ã³ã°ããŒ
ããã§éèŠãªã®ã¯ãJMeterããµã³ãã©ãŒèªäœã«å ¥åãããã³ãŒããã³ã³ãã€ã«ããã®ã¯ãã³ã³ãã€ã«ããŒãæå®ãããŠããå Žåã®ã¿ã§ãïŒCompilation Cache Keyãã£ãŒã«ãïŒã ãã¹ãèšç»å ã§äžæã®è¡ã§ããå¿ èŠããããŸãã ãã¡ã€ã«ãä»ããŠæ¥ç¶ãããã¹ã¯ãªããã®å Žåããã¡ã€ã«ãžã®ãã«ãã¹ã䜿çšãããããã³ã³ãã€ã«ããŒãå ¥åããå¿ èŠã¯ãããŸããã
JavaãšGroovyã®æåå
Groovyæ§æã«ã¯åŸ®åŠãªç¹ã1ã€ãããŸãã ãŸãã2çš®é¡ã®æååããããŸãã
- äºéåŒçšç¬Š-Groovyæåå
- åäžåŒçšç¬Šã§å²ãã -Javaæåå
詳现ã¯ãã¡ããã芧ãã ããã Groovyã¹ããªã³ã°ã«ã¯ã$ {expression}ãªã©ã®åŒã䜿çšããæ©èœããããŸãããã®åŒã¯ãã¹ããªã³ã°å ã§åŒå€ã«èªåçã«å±éãããŸãã ããã¯éåžžã«äŸ¿å©ãªãã€ã³ãã§ãããæå€ã«ãJMeterå€æ°ãåç §ããæ§æãšäžèŽããŸãã ã ããGroovyã§æžããš
currId = 123 log.info("Current ID: ${currId}")
åæã«ãcurrIdãšããååã®éåžžã®JMeterå€æ°ãçŸåšã®ã¹ã¬ããã§å®çŸ©ããããã®å€ãã¹ã¯ãªããã«çŽæ¥ä»£å ¥ãããŸãã ãŸãã1å眮æãããŸãã ãã®åŸãã³ãŒããã³ã³ãã€ã«ãããçµæããã£ãã·ã¥ãããŸãã ãããã£ãŠããã®ãããªåŒã§äœ¿çšãããå€æ°åãJMeterå€æ°ãšéè€ããªãããã«ããå¿ èŠããããŸãã ãŸããæ¬åœã«å€ãJSR223ãµã³ãã©ãŒã«æž¡ãå¿ èŠãããå Žåã¯ããã®ããã«Parametersãã£ãŒã«ãã䜿çšããå¿ èŠããããŸãã
å€éšãã¡ã€ã«ããœãŒã¹ã³ãŒããšããŠäœ¿çšããå ŽåãJMeterå€æ°çœ®æã¯çºçããŸããïŒãã£ãŒã«ãã§ã®ã¿çºçããŸãïŒãããã©ã¡ãŒã¿ãŒã䜿çšã§ããŸãã
Groovyæååã®æ©èœã䜿çšããäºå®ããªãå Žåã¯ãJavaæååã䜿çšããããšããå§ãããŸãïŒã€ãŸããåäžåŒçšç¬Šã§å²ã¿ãŸãïŒã ãŸããããã©ãŒãã³ã¹ã¯åäžããŸããããã¡ãã1ãããŒã§ãã
ãããã«
BeanShellãµã³ãã©ãŒã®åäœã¯ãäžè¬çãªã€ã³ã¿ãŒããªã¿ãŒã®åé¡ãã€ãŸãã€ã³ã¿ãŒããªã¿ãŒã³ãŒãã®é床ãé ãããšã瀺ããŠããŸãã BeanShellã«æ°è¡ãããªãå Žåã¯ãããããåé¡ã«æ°ä»ããªãã§ãããããå€ãã®ã³ãŒããããå Žåãã«ãŒããããå Žåã«ã¯ééããªãæ°ä»ãã§ãããã LoadRunnerã€ã³ã¿ãŒããªã¿ãŒã§ããŸã£ããåãåé¡ã芳å¯ãããŸããã
ãããŸã§ã«BeanShellã䜿çšãããã¹ãã®å®è¡ã«åé¡ããªãã£ãå Žåã¯ãä»åŸå®å šã«ãã¬ã€ããèªåã§ãã¹ããäœæããªãããšããå§ãããŸãã 代ããã«ãJSR223 + Groovyãããã«äœ¿çšããããšããå§ãããŸããããã«ãããããŒãã¹ããŒã·ã§ã³ã§ããã©ãŒãã³ã¹ã®åé¡ãçºçããå¯èœæ§ãäœããªããŸãã
èšäºããåãåºãéèŠãªãã€ã³ãã
- BeanShell Samplerã¯äœ¿çšããªãã§ãã ããã代ããã«ãJSR223 + Groovyã䜿çšããŸãã
- JSR223 + java =åãBeanShellãªã®ã§ãã»ã¯ã·ã§ã³1ãåç §ããŠãã ããã
- è€æ°ã®JSR223ã®ã³ãŒããçµ±åã§ããå Žåã¯ãå€éšãã¡ã€ã«ã䜿çšããŸãã ã³ãŒãã®éè€ãæé€ããããšèªäœãåªããããã°ã©ãã³ã°ã¹ã¿ã€ã«ã§ãããšããäºå®ã«å ããŠãCompilation Cache Keyã«ã€ããŠå¿é ããå¿ èŠã¯ãããŸããã
- çµã¿èŸŒã¿ã®ãµã³ãã©ãŒã¹ã¯ãªããã䜿çšããå Žåã¯ãCompilation Cache Keyãå¿ããªãã§ãã ããã
- bsh.sharedã®é¡äŒŒç©ãå¿ èŠãªå Žåã¯ãäžèšã®ãœãªã¥ãŒã·ã§ã³ã䜿çšããŸãã