Click here to Skip to main content
Click here to Skip to main content

To-Paw Speeds Up Sports Simulation Game With .NET Code Profiler

, 25 Mar 2004
No professional athlete would stop short for five seconds before scoring a touchdown, sinking a basket, or blasting a goal. Similarly, no statistical-based sports simulation game should require users to stare anxiously at a computer screen as they wait for game results to load.

Editorial Note

This article is in the Product Showcase section for our sponsors at CodeProject. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.

This is a showcase review for our sponsors at CodeProject. These reviews are intended to provide you with information on products and services that we consider useful and of value to developers.

Introduction

Business Objectives:

Identify bottlenecks within a soccer simulation game to improve performance and speed up database connectivity before commercial release in Fall 2003.

Technical Challenges:

Clocking in at seven seconds per game, To-Paw’s simulation engine was too slow for the commercial gaming market. Connecting to the Access database for league creation also took too long.

Solution:

Using Red Gate Software’s ANTS Profiler to identify slow processes in the application and adjust associated code.

Results:

To-Paw cut simulation time to less than two seconds per game, and improved application speed by at least 20 percent through more immediate database connectivity.

No professional athlete would stop short for five seconds before scoring a touchdown, sinking a basket, or blasting a goal. Similarly, no statistical-based sports simulation game should require users to stare anxiously at a computer screen as they wait for game results to load.

In an effort to appeal to the commercial gaming industry, To-Paw Software needed to find a way to speed up the database connections and improve performance of the simulation engine for its interactive soccer manager program.

Managing Virtual Sports Team

To-Paw Software is a two-man shop that specializes in creating statistics-based sports simulations. Its Indoor Soccer Manager, currently in public beta, is a realistic interactive representation of the popular pastime – from stats all the way to front office management. Players set up their own league and run a professional indoor soccer franchise – albeit a fantasy one – with customizable play-by-play and scouting reports, multi-player trades, full remote features, and play-by-email capability.

To-Paw tests its game code on a dual-boot IBM Thinkpad 600X for Linux and Windows 2000. It is written in VB.Net, with a combination of Visual Studio Standard and SharpDevelop for quick drafting of code. (SharpDevelop is a free IDE for C# and VB.NET projects developed on Microsoft's .NET platform. It's open source, so users can download both source code and executables from the Web). The beta open source program OpenOffice 1.0.1 is used for internal documentation, Enzip for archiving, and the NUnit framework for unit testing. An Access database file stores all of the league information.

The main thrust of the game is statistics, with reports produced in HTML and text format. Work to support XML is underway. The game currently runs on PCs, but an online version is slated for a future release.

So far, the game averages 50 to 60 downloads with each two-week release. The website, www.indoorsoccersim.com, averages 500 to 600 unique hits per day.

"One of the key areas of concern for a sport simulation of this genre is the ability to quickly get game results," says Jack Neal, Indoor Soccer Manager's lead developer. "It's not uncommon for players to want to simulate entire seasons at the push of a button, so the ability to make the engine light to load and run is crucial."

To-Paw's simulation times were moderately slow, coming in at five to seven seconds per game. That adds up when multiplied by more than 200 games per season. It also took too long to connect to the Access database for league creation.

"With only two people on staff, the process for dealing with these issues had to be cost effective and the tools extremely efficient," Neal says.

Reducing Timeouts

To-Paw had no formal process for locating and dealing with existing bottlenecks.

"Testing was basically based on intuition – blindly trying code out and setting up breakpoints," Neal says. "As such, I wasted a lot of time. Plus, by optimizing code that didn't need it, I ran the risk of possibly introducing new bugs or making the code harder to maintain."

After trying and failing with a few open source profilers that he came across on the Web, Neal decided to purchase Red Gate Software's ANTS Profiler. The tool identifies slow lines of code in .NET applications and pinpoints problems, allowing developers to modify routines or modules that aren't performing as originally intended.

"The drill-down in ANTS Profiler is wonderful," Neal says. "It is quite easy to see where the CPU is chugging. The display is easy to read, making it very apparent where things are bogged down."

Initially, Neal had figured that the engine itself was slow and needed some algorithms shaped up. After running ANTS Profiler, however, he realized that the code used for generating the game reports was what slowed the process down the most.

"After going through all the code that concatenated information for our reports and fixing some costly loops, the simulation engine's performance improved," Neal says. ANTS Profiler's ability to filter into and trace specific code also proved a great timesaver, allowing Neal to focus on the core areas of the program that he suspected were causing the most problems.

"Time was cut to less than two seconds per game," he says. "It was a very simple type of fix, but I never knew how profoundly it affected performance."

To-Paw also saw that moving all of the database connection code into a singleton type class (used for matching against a single known instance) would leave a connection always open. That change improved application speed by at least 20 percent – due primarily to the time saved in league creation, which requires heavy database access for creating the players, teams and league structure.

"All in all, it took me about a half hour after starting my task with the tool to accomplish what I set out to do," Neal says. "The people that buy our game once it does go commercial will benefit from ANTS Profiler."

"Don't waste time fixing nothing"

To-Paw plans to continue using ANTS Profiler as a finishing tool – checking initial construction of code as well as the algorithms being developed for enabling player trades, contracts, financial management, and statistical reporting. Eventually the company hopes to release other "minor" league sport simulation games, using ANTS Profiler to ensure efficient coding.

"The tool has helped me to look more critically at what I am creating," Neal says. "My first instinct as a programmer is simplicity, followed by performance. The ANTS Profiler makes sure that I don't waste time fixing nothing, and that I can see the program's execution very clearly in the interface."

Simplicity also means not getting locked into a large, integrated "bloatware" program. Because ANTS Profiler is a separate program, To-Paw can use it in conjunction with both commercial and open-source software and not be tied to a particular vendor.

Finally, there's the critical aspect of how a vendor listens and responds to its customers.

"What strikes me in addition to the tool's functionality and versatility is how the people at Red Gate go out of their way to contact me and check how the Profiler is working. They answer my questions satisfactorily and quickly – despite the time difference across the Atlantic – and interaction is polite, professional and accommodating. The company builds a solid product, and they stand behind it.

See how well ANTS Profiler will work with your applications – download a free, fully-functional trial.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

Share

About the Author

Red Gate Software
Red Gate Software Ltd.
United Kingdom United Kingdom
Red Gate Software makes ingeniously simple tools used by over 650,000 Microsoft technology professionals working with .NET (incl. ASP.NET), SQL Server, Azure, and Oracle. More than 100,000 companies use our products, including 93% of the Fortune 100.

Our philosophy is to design highly usable, reliable tools which elegantly solve the problems that developers and database administrators face every day.
Group type: Organisation

4 members

Follow on   Twitter   Google+

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.141223.1 | Last Updated 26 Mar 2004
Article Copyright 2004 by Red Gate Software
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid