Horizontal comparison of various physical projection performance in unity

Source: Internet
Author: User
Tags array length

Test Engineering:

Http://files.cnblogs.com/files/hont/RaycastTestProj.rar

Test method:

A random number of cubes within a radius, then a variety of projections are emitted at the center point for testing

Use the Unity5.3.4 version and test with Profiler and stopwatch to compare performance and GC differences

As the capsules and other projections are too slow, I use 1000 calls to test, Nonalloc cache array length of 20

Some projections are limited by distance.

usingUnityengine;usingSystem.Collections;usingSystem.Diagnostics; Public classboxcastalltest:monobehaviour{voidUpdate () {varStopWatch =NewStopwatch ();        Stopwatch.start (); Profiler.beginsample ("boxcastalltest");  for(inti =0; I < +; i++) {Physics.boxcastall (transform.position, Vector3.one*2f, Vector3.forward);        } profiler.endsample ();        Stopwatch.stop (); UnityEngine.Debug.Log ("StopWatch:"+stopwatch.elapsedmilliseconds); }}

Test results:
Name Speed GC Alloc
Raycast 1ms 0
Raycastall 2ms 273.4KB
Raycastnonalloc 1ms 0
Boxcast 18ms 0
Boxcastall 38ms 3.2MB
Boxcastnonalloc 36ms 0
Spherecast 86ms 0
Spherecastall 192ms 8.8MB
Spherecastnonalloc 183ms 0
Capsulecast 139ms -
Capsulecastall 449ms 19.6MB
Capsulenonalloc 263ms 0

The overhead of spherical projection and capsule projection is relatively large, and the overhead of various projections is much higher than that of direct emission rays.

Visible, if the first choice of Ray to judge, it will be a lot of game optimization help

Horizontal comparison of various physical projection performance in unity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.