0Jz@/e6FS(Z0最近研究一个开源的性能测试功能openSTA,网上资源确实太少,刚巧最近工作留给我的时间很少。
C\r B-@?09X {b:i&x]9]K$R`0今天无奈的我,还是逼自己静下心看Help文档了。有点小成果,赶紧记下来。
c+J.@g#i/v Q ^0#N*??dzMn9Vl `0将下面代码复制到 scrīpt Modeler 中,在Commander里运行,查看其Test Report Log。51Testing软件测试网2VD:mn%E/quA&VIP
w6i^
s k7P0!***************************代码头***************************!
!B|FA1~s+M(`\0Environment !1
Descrīption "" !2
Definitions !3
iNTEGER i (1-100), scrīpt !4
integer m,local !5
code !6
report "m=",m !7
ACQUIRE MUTEX "first" !8
next i !9
set m = i !10
report "m=",m !11
RELEASE MUTEX "first" !12
report "m=",m !13
d#k"W;q_ H0!***************************代码尾***************************!
COS0u4c G9n9i%I0'pvS.H&e#}]0t ?-r051Testing软件测试网"x
N-NN3I
51Testing软件测试网kv&bG2]q此脚本虽小,且简单,但你确可从中明白openSTA的一些实现过程。
|j3_.U$?051Testing软件测试网&LS y!l8u6yj(y2s一、从UserID你可以知道,并发的三个用户,开始运行是没有先后顺序的。
8|E;e8^8@;|0W2]8c%a7rc051Testing软件测试网]a(g4B)T%D-Q二、从Line#你可以知道,代码7行处的m一直等于0,代码11行、13行都是从1递增。51Testing软件测试网o$gS$^2P^!Y!B
51Testing软件测试网$J%f
]*K6P3s3L`Gw三、给我留下了一个疑点,ACQUIRE MUTEX 、RELEASE MUTEX 的作用和区别。51Testing软件测试网*d_9xl+B-on%y
Help文档描述如下:
51Testing软件测试网
]*s y.B'CACQUIRE MUTEX Command
51Testing软件测试网L*ZpCyj;ws+sxG@This command acquires exclusive access to a shared resource, known as a mutex. The mutex is identified by its name and scope (which must be either LOCAL or TEST-WIDE). A test-wide mutex is one that is shared by all scrīpts running as part of a distributed test; a local mutex is only shared between scrīpts running on the local node.
}6P;w bh)ytA0RELEASE MUTEX Command
P)u*rd!\fL0This command releases a named mutex. The mutex to be released is identified by its name and scope, which must correspond to the values specified on the corresponding ACQUIRE MUTEX command.
sY[
~'B L:I0看着这翻译和我的理解,结合这结果,让我很不理解
'A(r3|2dy6J+y0