SPECweb2009 Release 1.20 Support Workload Pseudocode

Version 1.20, Last modified 2010-04-29

The pseudo code specification provided is a description of the actual work that needs to be implemented. This is required so that results will be comparable. Any dynamic implementation must follow the specification exactly. This means that all operations specified, such as loops and searches, should be executed for each request. Unless otherwise specified, results or intermediate results from previous operations or requests should not be cached.

To provide the flexibility needed to implement this code on any platform and in any desired scripting language, the subroutines listed in the pseudo code may be inlined or subdivided into smaller subroutines as long as the algorithms implemented by the subroutines are performed exactly as described.

The dynamic operations must be executed by separate dynamic modules. The dynamic code must be written in a widely-used scripting language. Script implementations in PHP and JSP are supplied with the kit.

1.1.1 Definitions of Terms

BESIM
Backend Simulator, that resides on a separate physical machine than the primary SUT.  See User's Guide for more details.
QUERYSTRING
Information following the '?' in the URL.
PADDING
A file generated by wafgen that brings the dynamic script up to the sizes observed in real-world pages (that use JavaScript, CSS, etc.)

Note: Directories are specified in this document with a forward slash, '/', however, this in no way implies that one has to follow this convention. Use what works on one's operating system.

1.1.2 Specification of Return Formats

All of the dynamic requests return one of the following types of HTML pages to the client. These formats must be followed precisely for the client software to understand the returned pages. This includes the blank line between the headers and the <html> tag.

Square brackets, [], are used to denote either a looping construct (If/Else/End If, Foreach, etc.), or where appropriate text should be substituted. This text should contain only the required information.  The text may NOT be padded in any way to create a fixed length field.

Curly braces, {}, are used to denote an array that can contain multiple variables inside of it.  Arrays are not strictly required for implementing these constructs; they are used to indicate a logical grouping of variables.

Extra headers required by the web server are allowed. The formats simply show the minimum required by the benchmark.

Successful Page Template
HTTP 200 OK
Content-type: text/html
Cache-Control: no-cache
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8858-1" />
<link href="style.css" rel="stylesheet" type="text/css">
<title>SPECweb2009: Support [TITLE]</title>
</head>
<body>
<!-- SPECweb2009 Dynamic Data Area -->
<!-- SPECweb2009 Displayable Page Title -->
<h1>SPECweb2009: Support [TITLE]</h1>
<!-- SPECweb2009 User Action Area for Links and Forms -->
[BODY]
<!-- SPECweb2009 Embedded Text -->
<pre>
[PADDING]</pre>
</body>
</html>
Error Page Template
HTTP 200 OK
Content-type: text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8858-1" />
<link href="style.css" rel="stylesheet" type="text/css">
<title>SPECweb2009: Support Error</title>
</head>
<body>
<!-- SPECweb2009 Error Page -->
<div class="error">
<h1>Script Error</h1>
<p>[ERROR MESSAGE]</p></div>
</body>
</html>

1.2.1 Pseudocode for BESIM query subroutine

    [If BESIM_COUNT > 1]   (NOTE: BESIM_COUNT defined from the init page below)
        Seed random number generator (if necessary)
        Select a BESIM_HOST and BESIM_PORT to use below (random or round-robin)
    [End If]
    Open (or reuse a previously opened) socket to BeSim
    [If HTTP request to "http://' + BESIM_HOST + ':' + BESIM_PORT + BESIM_URI + "?2&[REQUEST]" unsuccessful]
        Report Error Message = 'Failed to open BeSim stream'
	Return empty array
    [End If]
    Skip past '<pre>' tag in BESIM response
    Set Errno = [First line in BESIM response after '<pre>' line]
    [If Errno not 0]
         Report Error Message = 'BeSim returned with an error number: ' + Errno
         Return empty array
    [End If]

    [Foreach line in BESIM response until line == '</pre>']
          BESIM_RESULTS_ARRAY += line;
    [End Foreach]

    Return BESIM_RESULTS_ARRAY

1.2.2 Pseudocode for init page

Sample request:
GET /support/init.php?BESIM_HOST=besimhost1+besimhost2&BESIM_PORT=81+82&BESIM_URI=/isapi-bin/ \
besim_zisapi.api&BESIM_PERSISTENT=true&PADDING_DIR=/www/web2009/support/dynamic_ \
padding/&SMARTY_DIR=/www/web2009/Smarty-2.6.6/libs/&SMARTY_SUPPORT_DIR=/www/web2 \
005/support/&SEND_CONTENT_LENGTH=true HTTP/1.1
    [Foreach name, value pair in QUERYSTRING]
        Set name = value   (NOTE: these must persist across script executions)
    [End Foreach]
    Set BESIM_COUNT = [# BESIM_HOST/BESIM_PORT pairs]

    Set SERVER_TIME = [# milliseconds since the Unix Epoch]

    Return Page with HTML = 
<html>
        <head>
                <title>SPECweb2009 Support Workload Init</title>
        </head>
        <body>
<P>SERVER_SOFTWARE = [Substitute web server variable: "SERVER_SOFTWARE"]</P>
<P>REMOTE_ADDR = [Substitute web server variable: "REMOTE_ADDR"]</P>
<P>SCRIPT_NAME = [Substitute web server variable: "SCRIPT_NAME"]</P>
<P>QUERY_STRING = [Substitute web server variable: "QUERY_STRING"]</P>
<P>SERVER_TIME = [SERVER_TIME]</P>
        </body>
</html>

1.2.3 Pseudocode for index page

Sample request: GET /support/index.php
    Set TITLE = 'Home'
    Set PRODUCT_CATEGORY_ARRAY = [BESIM query with REQUEST = '1']
    Set BODY = 
<h2>Product Categories</h2>
<ul>
    [Foreach line in PRODUCT_CATEGORY_ARRAY]
<li><a href="catalog.php?id={line[ID]}">{line[NAME]}</a></li>
    [End Foreach]
</ul>
<h2>Product Search</h2>
<form name="productSearch" method="GET" action="[SEARCH PAGE]">
<input name="q" value="">
<input type="submit" value="Search"></form>

    If '[PADDING_DIRECTORY]/index' exists then
        Set PADDING = File contents of '[PADDING_DIRECTORY]/index'
    Else
        Print 'Unable to locate padding file.'
    Endif
    Return Successful Page

1.2.4 Pseudocode for catalog page

Sample request: GET /support/catalog.php?id=220
    If QUERYSTRING['id'] not set then
         Redirect to index page
    Endif
    Set PRODUCT_LISTING_ARRAY = [BESIM query with REQUEST = '2&{QUERYSTRING['q']}']
    Set TITLE = 'Category {QUERYSTRING['id']}'
    Set BODY = 
	<ul>
    [Foreach line in PRODUCT_LISTING_ARRAY]
<li><a href="product.php?id={line[ID]}">{line[NAME]}</a></li>
    [End Foreach]
</ul>
    If '[PADDING_DIRECTORY]/catalog' exists then
        Set PADDING = File contents of '[PADDING_DIRECTORY]/catalog'
    Else
        Print 'Unable to locate padding file.'
    Endif
    Return Successful Page

1.2.5 Pseudocode for search page

Sample request: GET /support/search.php?q=memory+cable+disk
    If QUERYSTRING['q'] not set then
         Redirect to index page
    Endif
    Set SEARCH_RESULTS_ARRAY = [BESIM query with REQUEST = '3&{QUERYSTRING['q']}']
    Set TITLE = 'Search Results for {QUERYSTRING['q']}'
    Set BODY = 
	<ul>
    [Foreach line in SEARCH_RESULTS_ARRAY]
<li><a href="product.php?id={line[ID]}">{line[NAME]}</a></li>
    [End Foreach]
</ul>

        <h2>Product Search</h2>
        <form name="productSearch" method="GET" action="search.php">
                <input name="q" value="">
                <input type="submit" value="Search"></form>
    If '[PADDING_DIRECTORY]/search' exists then
        Set PADDING = File contents of '[PADDING_DIRECTORY]/search'
    Else
        Print 'Unable to locate padding file.'
    Endif
    Return Successful Page

1.2.6 Pseudocode for product page

Sample request: GET /support/product.php?id=1814
    If QUERYSTRING['id'] not set then
         Redirect to index page
    Endif
    Set DOWNLOAD_CATEGORIES_ARRAY = [BESIM query with REQUEST = '4&{QUERYSTRING['id']}']
    Set LANGUAGES_ARRAY = [BESIM query with REQUEST = '5']
    Set OPERATING_SYSTEMS_ARRAY = [BESIM query with REQUEST = '6&{QUERYSTRING['id']}']
    Set TITLE = 'Product {QUERYSTRING['id']}'
    Set BODY = 
	<form name="filters" action="[file catalog page]" method="GET">
		<input type="hidden" name="id" value="{QUERYSTRING['id']}">
		<h2>Download Category</h2>
		<select name="category">
    Counter = 0
    [Foreach line in DOWNLOAD_CATEGORIES_ARRAY]
<option label="{line}" value="[Counter]">{line}</option>
    [Increase Counter by 1]
    [End Foreach]
</select>

		<h2>Operating System</h2>
		<select name="os">
    Counter = 0
    [Foreach line in OPERATING_SYSTEMS_ARRAY]
<option label="{line}" value="[Counter]">{line}</option>
    [Increase Counter by 1]
    [End Foreach]
</select>

		<h2>Language</h2>
		<select name="lang">
    Counter = 0
    [Foreach line in LANGUAGES_ARRAY]
<option label="{line}" value="[Counter]">{line}</option>
    [Increase Counter by 1]
    [End Foreach]
</select>
		<div class="controlPanel"><input type="submit" value="proceed"></div>
	</form>
    If '[PADDING_DIRECTORY]/product' exists then
        Set PADDING = File contents of '[PADDING_DIRECTORY]/product'
    Else
        Print 'Unable to locate padding file.'
    Endif
    Return Successful Page

1.2.7 Pseudocode for fileCatalog page

Sample request: GET /support/fileCatalog.php?id=1814&category=1&os=9&lang=24
    If QUERYSTRING['id'] not set then
         Redirect to index page
    Endif
    If QUERYSTRING['category'] or QUERYSTRING['os'] or QUERYSTRING['lang'] not set then
         Redirect to product page + QUERYSTRING['id']
    Endif
    Set FILE_LISTING_ARRAY = [BESIM query with REQUEST = '7&{QUERYSTRING['id']}& \
                              {QUERYSTRING['category']}&{QUERYSTRING['os']}&{QUERYSTRING['lang']}]
    Set TITLE = 'Product {QUERYSTRING['id']} - Files'
    Set BODY = 
    [Foreach line in FILE_LISTING_ARRAY]
	<div class="file">
	<span class="name">{line[name]}</span>
	<span class="details">{line[details]}</span>
	<p>{line[description]}</p>
	<div class="links"><a href="[file page]?id={line[FileID]}>Download</a></div>
	</div>
    [End Foreach]
    If '[PADDING_DIRECTORY]/fileCatalog' exists then
        Set PADDING = File contents of '[PADDING_DIRECTORY]/fileCatalog'
    Else
        Print 'Unable to locate padding file.'
    Endif
    Return Successful Page

1.2.8 Pseudocode for file page

Sample request: GET /support/file.php?id=38722
    If QUERYSTRING['id'] not set then
         Redirect to index page
    Endif
    Set FILE_DETAILS_ARRAY = [BESIM query with REQUEST = '8&{QUERYSTRING['id']}]
    Set TITLE = 'File {QUERYSTRING['id']}'
    Set BODY = 
	<table>
		<colgroup>
			<col class="field" />
			<col class="value" /></colgroup>
		<tr>
			<td>Name:</td>
			<td>{FILE_DETAILS_ARRAY[NAME]}</td></tr>
		<tr>
			<td>Size:</td>
			<td>{FILE_DETAILS_ARRAY[SIZE]}</td></tr>
		<tr>
			<td>Date:</td>
			<td>{FILE_DETAILS_ARRAY[DATE]}</td></tr></table>
	<h2>Description</h2>
	<p>{FILE_DETAILS_ARRAY[DESCRIPTION]}</p>
	<h2>Additional Information</h2>
	<p>{FILE_DETAILS_ARRAY[ADDITIONALINFO]}</p>
	<a href="{FILE_DETAILS_ARRAY[URL]}">Download</a>
    If '[PADDING_DIRECTORY]/file' exists then
        Set PADDING = File contents of '[PADDING_DIRECTORY]/file'
    Else
        Print 'Unable to locate padding file.'
    Endif
    Return Successful Page

1.2.9 Error Reporting

The dynamic code must handle errors by returning an HTML page with an error message in it, using the Error Page Template specified above. The pseudo-code for each request contains examples of errors that might be reported and how this reporting should be done.


Copyright © 2005-2010 Standard Performance Evaluation Corporation.  All rights reserved.