07.11.2014 Views

Enterprise Library Test Guide - Willy .Net

Enterprise Library Test Guide - Willy .Net

Enterprise Library Test Guide - Willy .Net

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Using the <strong>Test</strong> Cases 243<br />

Verification<br />

Running the two test cases again after applying the preceding code examples verified<br />

that the cost of creating a domain object with the FileConfigurationSource class was<br />

within acceptable limits.<br />

Specific Performance <strong>Test</strong>s<br />

Specific aspects of each application block were also tested to see if their performance<br />

was acceptable. This section discusses performance issues that were found in the<br />

Data Access Application Block, the Logging Application Block, and the Cryptography<br />

Application Block.<br />

<strong>Test</strong>ing the Logging Application Block<br />

The Logging Application Block was tested to determine the cost of logging messages<br />

to a database trace listener. To pass the test, the cost of logging to a database trace<br />

listener should be scalable. If the number of transactions per second decreases as the<br />

number of requests increases, there is a bottleneck.<br />

<strong>Test</strong> Case<br />

To run the test case, the application block was first configured to use a database trace<br />

listener to log messages to a database. The test case logged messages to the database<br />

with the Logger.Write method. A performance test tool was used to analyze the<br />

results.<br />

Problem<br />

The results from the performance test showed that the transactions per second decreased<br />

when the numbers of users increased. This decrease occurred because, with<br />

a large number of users, there was significant contention for access to the database<br />

trace listener.<br />

This contention exists because the LogSource class enumerates through all the trace<br />

listeners that the application block is configured to use and calls each trace listener’s<br />

TraceData method. Before calling the method, the LogSource class first checks to see<br />

whether the trace listeners are thread safe by calling each trace listener’s IsThread-<br />

Safe property. It locks a trace listener if it is not thread safe. The FormattedDatabaseTraceListener<br />

class derives from FormattedTraceListenerBase, which has the<br />

IsThreadSafe property set to false. This means that the FormattedDatabaseTraceListener<br />

class is locked for every call to its TraceData method. This is why there is<br />

contention for access to the database trace listener.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!