Faster Parallel.For
Casey Walsh-Warder
$0.0
(no ratings)
Date |
Price |
---|---|
日期和时间 |
价钱($) |
11/12(2022) |
0.0 |
11/16(2024) |
0.0 |
Jump AssetStore
Parallelize your code to speed it up several times. It's like C#'s Parallel.For, but simpler and faster.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.The package includes documentation, examples, and almost all source code. It just excludes a tiny bit of C++ code.FeaturesIt has two methods, the primary one is:static void For(int length, Action 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.CompatibilityUnity Version: 2020.3.0 or higher.OS: Tested with Windows and Android.