Faster Parallel.For View on Asset Store (opens in new tab)

Package details

Latest version
1.0
Last updated
First released
Unity version
2020.3.0 or later
Package size
124 KB
Files
20
Favorites
11
Views in the past week
4

Price tracking

Last checked
Tracked since
Lowest recorded
Free on

Keywords

Faster Parallel.For

by Casey Walsh-Warder (opens in new tab)

1 rating, too few to average

Parallelize your code to speed it up several times. It's like C#'s Parallel.For, but simpler and faster.

Price Free

Get it free on Asset Store (opens in new tab)

Affiliate link · Purchases support this site

Price history

Last 6 months

USD
Price history for Faster Parallel.For, 6 months Current Free; lowest Free; highest Free in this period. $0 Jun Jul Aug Sep Oct Nov

Asset preview

1 / 5

Faster Parallel.For screenshot 1

Faster Parallel.For screenshot 1

About this asset

If your game needs better performance, sometimes parallelism is the answer.

This is a parallel for loop. With a normal for loop, you usually do something with 0, then 1, then 2, and so on, such as changing the value at each index of an array. With a parallel for loop, you can use multiple CPUs to process several at a time. That can make your code run several times faster.

You can already use a parallel for loop in C#. C#'s Parallel.For isn't designed for games though. It has a lot of features, but too much overhead for calling multiple times each frame. It also produces garbage, causing lag spikes.

Faster Parallel.For is (hopefully) faster and doesn't produce garbage.

From the publisher's Asset Store listing.

Technical details

The package includes documentation, examples, and almost all source code. It just excludes a tiny bit of C++ code.

Features

It has two methods, the primary one is:

static void For(int length, Action<int> body)

You'll write the body delegate's code. It executes body(0), body(1), ..., and body(length - 1) in a parallel fashion. The documentation explains in more detail.

The package's second method reduces the scheduling priorities of the worker threads.

Compatibility

  • Unity Version: 2020.3.0 or higher.
  • OS: Tested with Windows and Android.