An approach to 95th Percentile with SIMD

Introduction

In a previous post I looked into using Single instruction, multiple data, SIMD to Sum an array of integer elements and to find the Median value of sample.

When working with statistical data, we often need to find the 95th percentile element of a sample. Calculating the Sum is useful for finding the mean value but finding the 95th percentile element requires a different approach. However, the P95 algorithm is similar to the way the Median element is found.

The 95th percentile is a statistical term that means the value below which 95% of the data in a given set is found. For example, if you have a set of test scores, the 95th percentile score is the one that is higher than 95% of the other scores. You can calculate the 95th percentile using this formula: n = (P/100) x N, where P = percentile, N = number of values in the data set, and n = ordinal rank of the given set. The 95th percentile is often used to measure service response times, as it allows for burstable usage patterns.

Find out more


An approach to median with SIMD

Introduction

In a previous post I looked into using Single instruction, multiple data, SIMD to Sum an array of integer elements.

When working with statistical data, we often need to find the mean/median element of a sample. Calculating the Sum is useful for finding the mean value, but finding the median element requires a different approach.

The definition of median in case of

Find out more


CHttp Visual Studio Code Extension

I have been recently working on CHttp which is a tool to send HTTP requests and to measure the performance of REST APIs.

The primary goal of the tool is the ability to measure GET HTTP requests using version HTTP/2 and HTTP/3. As the tool is based on .NET (currently version 8), it requires a reasonably up-to-date Windows installation or the libmsquic package in case of Linux.

The standalone tool can be installed from GitHub, as a dotnet tool by using the dotnet tool install -g LaDeak.CHttp command or by as a Visual Studio Code Extension.

Using CHttp Visual Studio Code Extension

Find out more


Sum with SIMD

One of my projects requires to calculate an average over about a hundred integer values. These values are available in an array, I used the Sum extension method from Linq to calculate the sum of them.

I have learned two things about this method:

  • With the current version of .NET, it does seem to use vectorization to calculate the sum of items.

  • It uses checked arithmetic, meaning that it throws an exception in case of an overflow.

This is the (optimized) assembly code generated by the JIT for the Sum method:

Find out more


AI for Unit Testing

I work in an environment where people seek opportunities for using AI such as GitHub Copilot to perform daily development tasks.

While there is a general agreement that such tools can accelerate the development process, there is still some uncertainty about how they achieve this. Some possible explanations include quick refactoring options, automatic unit test generation, CI/CD YAML file generation, and assistance with integration testing. The last point refers to UI testing or end-to-end testing, while the second point narrows the focus to unit testing specifically. Although AI can help with most of these points, unit testing seems like an anti-pattern when looking into the details.

My Unit Testing process

Writing unit tests is a well-understood and daily practiced process. In fact, I have seen multiple projects accumulating tens of thousands of tests over their lifetime and developers create unit tests daily. There are numerous generic posts detailing the testing best practices or focusing on special aspects such as Performance testing within Unit tests bad idea.

Find out more