G'day JavaRequest
Ian Blavins Contract Performance Engineer Temenos -----Original Message----- From: Stuart Findlay [mailto:[EMAIL PROTECTED] Sent: 10 September 2007 10:30 To: JMeter Users List Subject: Re: A question of efficiency Thanks Ian just to clarify - are you referring to ExampleSampler.java and ExampleSamplerGui.java or JavaRequest? Stuart iblavins wrote: > G'day > > It takes a few minutes to do but I would suggest creating a Java sampler to > act as a 'gateway' (in the non technical sense) to Java functionality. > > You can pass parameters into the sampler via the normal sampler parameter > interface and use a regular expression parser to get the result back into > JMeter variables. The sampler can use arbitrary Java functionality to > transform the input to the output. (Just because it is a sampler doesn't > mean it has to call a server and normally you won't). > > You then add the sampler to your test plan in the normal way to compute > values wherever you need them. > > Once you have one it is easy to either add more functionality to it or to > clone it for different functionality. > > There is a sample Java sampler among the JMeter resources. > > Be advised that, because JMeter runs in a single JVM on each JMeter server, > things like static variables work across all instances of the sampler on > that JMeter server (for good or bad). > > > > Ian Blavins > Contract Performance Engineer > Temenos > > > > -----Original Message----- > From: Stuart Findlay [mailto:[EMAIL PROTECTED] > Sent: 10 September 2007 09:26 > To: JMeter User Group > Subject: A question of efficiency > > Hi all > > I'm looking for some answers and opinions in relation to using BeanShell > functions and the efficiency of JMeter scripts calling them. > > I'm load testing a calendar application and need to generate and > manipulate random dates in the iCal DTSTAMP format i.e. 20070910T090800Z > for the time of writing this mail. > > I found that for some of the more complex operations such as generating > random dates within a given timeframe and then adding hours, days or > weeks onto these it was very cumbersome to do this using JMeter alone so > I settled on BeanShell functions using the Calendar class to manipulate > dates and the following functions to convert the dates: > > > // Convert Java Calendar object to iCal timestamp > String calendarToTS(Calendar cal) { > String ret = String.format("%1$tY%1$tm%1$tdT%1$tH%1$tM%1$tSZ", new > Object[] {cal}); > > return ret; > } > > // Convert iCal timestamp to Java Calendar object > Calendar tsToCalendar(String ts) { > Calendar ret = Calendar.getInstance(); > > ret.set(Calendar.YEAR, new Integer(ts.substring(0,4))); > ret.set(Calendar.MONTH, new Integer(ts.substring(4,6)) - 1); > ret.set(Calendar.DATE, new Integer(ts.substring(6,8))); > ret.set(Calendar.HOUR_OF_DAY, new Integer(ts.substring(9,11))); > ret.set(Calendar.MINUTE, new Integer(ts.substring(11,13))); > ret.set(Calendar.SECOND, new Integer(ts.substring(13,15))); > > return ret; > } > > > > When I run a load test the jmeter process uses about 90% of the cpu on a > 4 CPU solaris box which would normally only see about 20% load with an > equivalent script which doesn't call any BeanShell functions. > > Does anyone have any suggestions for a more efficient way off accessing > Java functionality from JMeter. > > Thanks, Stuart > > ps - apologies for the half message sent by mistake beforehand. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > This email (and any attachments) contains confidential information, and is intended > only for the named recipient. Distribution or copying of this email by anyone > other than the named recipient is prohibited. If you are not the named or > intended recipient, please notify TEMENOS or the sender immediately and > permanently destroy this email (and any attachments) and all copies of it. No > member of TEMENOS Group AG or any of its associated or affiliated companies is > liable for any errors or omissions in the content or transmission of this > email. Any opinions contained in this email are solely those of the author and, > unless clearly indicated otherwise in writing, are not endorsed by any member > of TEMENOS Group AG or any of its associated and affiliated companies. > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] This email (and any attachments) contains confidential information, and is intended only for the named recipient. Distribution or copying of this email by anyone other than the named recipient is prohibited. If you are not the named or intended recipient, please notify TEMENOS or the sender immediately and permanently destroy this email (and any attachments) and all copies of it. No member of TEMENOS Group AG or any of its associated or affiliated companies is liable for any errors or omissions in the content or transmission of this email. Any opinions contained in this email are solely those of the author and, unless clearly indicated otherwise in writing, are not endorsed by any member of TEMENOS Group AG or any of its associated and affiliated companies. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

