Formatting scaled numbers

Standard formatting in .NET is sometimes not enough to fill specific requirements. For example, when high-level financial reports from big corporations need to be produced, the numbers dealt-with are generally around hundred of millions. Consider the following report where the scale and the currency (M$) is being displayed in the row header.

Quarter 1Quarter 2
New York (in M$)102.7621.40
Florida (in M$)32.7667.40

In order to achieve this formatting, a straightforward solution would be to apply a scaling factor to the numbers beforehand.

string.Format("{0:N2}", valueToFormat / 1000000); 

Sometimes, it is not appropriate nor possible to scale the numbers. In this situation, number scaling using the "," custom specifier could be used. Note the use of two commas since the number to be formatted is divided by 1000 for each comma:

decimal valueToFormat = 1345278000.346M;
string.Format("0:#,#,,", valueToFormat ); // displays 1,345 with the invariant culture

MWSnap Review

MWSnap Icon When it comes to create screenshots, I often use MWSnap, a freeware written by Mirek Wojtowicz. This tool offers all the core functionalities one may expect from a screenshot application. MWSnap was recommended to me by Michael Olivero.

MWSnap

Order returned by GetMethods

When calling the GetMethods function which lists the methods for a given type, we should keep in mind that this function does not return methods in a particular order. More specifically, the methods are not necessarily in the same order it has been declared in the source code. This discrepancy is due to some caching performed by the .NET Framework for better performance as explained in a post by Haibo Luo. This article is aimed at outlining solutions to order the methods returned by GetMethods in the declaring order.

CanShrink and CanGrow Behaviors

In Reporting Services (SSRS), the CanGrow property indicates whether the size of the text box can increase vertically according to its content. Similarly, CanShrink decreases the height of the text box according to its content. Controlling dynamically the height of report elements is only possible through these properties since the Height property cannot be bound to an expression. These two properties are therefore useful to create reports which can be scaled to both small and large contents. Unfortunately, CanGrow and CanShrink behave differently for each rendering extension.

Load Testing using The Grinder

Performing preliminary load testing on web applications does not require the use of complex tools such as Load Runner. An open-source tool called The Grinder provides a simple way for developers to perform load testing before handing out the application to Quality Assurance. With The Grinder, the load tests are defined using Jython scripts, and then are run by agents which could be distributed over the network. A property file defines which load tests should be run, how many times, and on how many threads. A central application referred to as the console starts the agents, collects the responses, and monitors the number of requests per second (RPS). The authors of this tool provide a short but useful overview of the architecture.

Installing The Grinder is a matter of unzipping the archive since the tool is written in Java. However, making the tool work as indented requires to dig into the documentation a little bit. This article is intended to assist people interested in getting up and running the tool on a Widows environment as quickly as possible.

Pages

Subscribe to Front page feed