Raycasting 1000 times

Hello Guys,
I am working on a simulation program where I need to cast 1000 ray from an object in each frame. Is this possible to do it so fast in each frame and still the program must run smoothly or even 100 milliseconds for 1000 rays.
I saw in a blog that instead of using Physics.Raycast we can use collider.raycast to reduce the ray casting time since collider.raycast only casts 1 ray.

this is what I am trying as an example but I will change the angle of each ray in my actual implementation.

using UnityEngine;
using System.Collections;

public class RaycastTest : MonoBehaviour {
	float time = 0;
	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		Vector3 fwd = transform.TransformDirection(Vector3.forward);
		time = 0;//Time.deltaTime;
		Ray ray = new Ray(transform.position,transform.forward);//Camera.main.ScreenPointToRay(Input.mousePosition);
		RaycastHit hit;
		Collider collider = this.collider;
		for (int j = 0; j < 1; j++) {
			print ("Time:"+time);
						for (int i   = 0; i < 1000; i++) {
								print ("There is something in front of the object!");
								if (collider.Raycast (ray,out hit, 50.0f)) {
										
										
								}
								Debug.DrawLine(ray.origin, hit.point);
						}
			time += Time.deltaTime;
			print("Time:"+time);
				}


	}
}

Any help is appreciated.
Thanks in advance.

If you find yourself needing 1000 raycasts, there is probably a simpler way to do what you’re doing.

Generally speaking, each raycast is something like O(log n) complexity for colliders in the scene. They’re well optimized to be very fast, but at some point you’re going to slow down the game.

If you can consolidate some of those casts – for example, into a spherecast – that will be a much lighter load.

It’s not unheard of to fire dozens or hundreds of raycasts per frame, but this can be one of those scenarios where a bit of effort toward optimization can be well worth it.

Hey Guys, I have a simple Solution

for(int i = 0;i < 500;i++)
{
Physics.Raycast…
//Do not put any print or debug statements.Only the variables. Ray casting is very fast but the other statements take up lot of time.
}