Go to content Go to sidebar

BeanShell Timer in JMeter

I was stress testing an application with JMeter when I discovered that the bottleneck was in the application setup rather than the actual application logic. My first reaction was to use a ramp to spread each thread's application setup over time with a throughput controller as a starting gate once all the threads had been properly initialized. But the throughput controller wasn't working for me, so I tried a BeanShell Timer instead.

My plan was to use a variable length delay for each delay. If the application setup was roughly constant for each thread, then I could let all the threads enter the application logic at roughly the same time. I was unable to find an good example of a BeanShell Timer using both arguments and environment variables, so I decided to document mine.

The number of threads and the startup ramp duration were established as User Defined Variables, allowing them to control the Thread Group and to be accessed by my BeanShell Timer via a vars.get(parameter-name). The thread loop counter was passed into the Timer as an argument, accessed via bsh.args[].

Getting the proper delay was easy once I determined how to access the number of threads, ramp duration and thread loop counter.

Take the JMeter BeanShell Timer Test Script for a test ride.

count = Integer.parseInt(vars.get("ThreadCount"));
ramp = Float.parseFloat(vars.get("RampPeriod"));

num = Integer.parseInt(bsh.args[0]); Integer sleep = 500 + 1000 * (count - num) * ramp / count;

log.info( "Sleep for " + sleep.toString() + " milli-seconds" ); return sleep;


Textpattern custom_url_func upgrade

My upgrade to Textpattern 4.2.0 was almost trouble free. The only problem was that the built-in newer, older, category1 and category2 functions weren't working.

After crawling through the source, I realized that the custom_url_func function signature had been redefined to include an optional argument. This change allowed the custom_url_func to be invoked by the newer, older, category1 and category2 functions (amongst others). Once I understood the problem, it was easy to add the required functionality.

function idx_permlinkurl($article_array, $link_type=0)
{
    global $prefs;

if (empty($article_array)) return; extract($article_array);

if ( $link_type == PAGELINKURL ) { // PAGE LINK mode $page = $article_array['pg']; if ( empty($page) || $page == 0 || $page == 1 ) { $page_suffix = ''; } else { $page_suffix = '?pg='.$page; }

$category = $article_array['c']; if ( !empty($category) ) { if (empty($page_suffix)) { $page_suffix = '?c='.$category; } else { $page_suffix = $page_suffix . '&c=' . $category; } }

$section = $article_array['s']; if ($section == 'default') { return hu.$page_suffix; } else { return hu.$section.$page_suffix; } } else { // ARTICLE LINK mode if (!isset($title)) $title = $Title; if (empty($url_title)) $url_title = stripSpace($title); if (empty($thisid)) $thisid = $ID;

if ($prefs['attach_titles_to_permalinks']) { return hu."id/$thisid/$url_title"; } else { return hu."id/$thisid/"; } } }

$prefs['custom_url_func'] = 'idx_permlinkurl';

iPhone Newbie - Scroll to Top

Scroll to the top of scrollable content by tapping the status bar at the iPhone display (status bar shown below).

iPhone Status Bar

Courtesy of 10 useful iPhone tips and Tricks

My complete list of iPhone usage tips.


Time Capsule Repair

Symptoms of Failure

Our problems started with Time Machine backups starting, but not completing. We were also having difficulty shutting down. When I dug deeper, I had similar problems with the sparse bundles in Disk Utility. The problems went away when I switched Time Machine over to a different hard drive.

Why Repair?

Our backup strategy called for hard drive cloning every two or three months with Time Machine for incremental backup. I considered staying on the external drive, but it was an effort to even get a weekly backup on the external drive. And the Time Capsule is so nice when you have laptops. This was also an opportunity for me to upgrade to a 1TB hard drive.

The Repair

The repair went smoothly with an assist from the internet. Brandon Hansen’s Hard Drive Repair for Time Capsule was particularly helpful. If you are comfortable installing a hard drive or card in a computer, then you probably have all the skills you need.

After Action Report

My fan power connector was found disconnected during the repair. I may have done it myself during the disassembly, but I can’t help but wonder if the problems were caused by over heating after the connector came loose.

I had no problems accessing the old hard drive using my USB hard drive adaptor. Disk Utility reported a bunch of errors when repairing the sparse bundles, but was successful in the end. I don’t expect to need the old data, but I’ll keep it for a few months just in case.


iPhone Newbie - Display Song Lyrics

All idioms are learned; good idioms are only learned once.
— Alan Cooper

Display song lyrics on your iPhone by touching the cover art while the song is playing.
Displaying lyrics while playing songs

Which raises the question of how to populate lyrics data: use Needle Drop to cycle through songs in iTunes and Harmonic or GimmeSomeTune to retrieve and store the lyrics of the current song.

My complete list of iPhone usage tips is maintained in a TiddlyWiki.

Previously:


iPhone Newbie - ScreenShot and Lists

All idioms are learned; good idioms are only learned once.
— Alan Cooper

It seems obvious once you know it, but it took me a while to remove Cupertino, CA from my list of cities in the Weather app. Click on the thumbnails below to view larger images.

  1. Take a iPhone ScreenShot by selecting the home and sleep buttons simultaneously.
  2. Reorder items in a TableView control by touching the grab bars on the right (circled in red) and sliding up or down.
    Moving items in an iPhone list
  3. Delete items in a TableView control by selecting the red circle with a horizontal bar. The circle will rotate and a Delete button will appear on the right.
    Delete item from an iPhone list

My complete list of iPhone usage tips is maintained in a TiddlyWiki.

Previously:


Prowl for iPhone

If you’re a techie with an iPhone, then you need to get Prowl. Ostensibly a client allowing Growl to push notifications to your desktop to your iPhone, the 3rd party API allows push notifications from any computer connected to the internet.

I’ve been too cheap for SMS, but a one time investment of $2.99 in Prowl fits into anyone’s budget. Now I just need Zac West to make enough money to keep the server going.


« Previous