Which code do you prefer for performance?

I write and search fall down code for 2d game. Both codes run is Update function. Which one of the more performance? These codes runs 3-4 active game objects (attached scripts) in gameplay.

First one is;

number.transform.Translate (new Vector2 (0, Global.globalInstance.objectDropSpeed) * Time.deltaTime);

Second one is;

float fallSpeed = 2 * Time.deltaTime;
transform.position -= new Vector3(0, fallSpeed, 0);

They are probably both very close to the same cost and will be an utterly insignificant amount of time if you’re just running it a few times a frame. You could setup a test where you run each bit of code within a for loop of hundreds of thousands of iterations, but the difference would only show up at that scale.

In general, write code based on clarity/correctness first and the only worry about optimizing when the profiler tells you that code is actually a bottleneck.

I prefer the first one but I am not that good so don’t blame me for an error but I think the first one.

In this case I guess the first one is better, less variables equals less memory to allocate. But if you need to access the fall speed later to another calculation, the second way is better.

But a tip in this case: To optimize the performance is better to avoid calling construction methods (like new Vector3() or new Vector2()) in the update because it will take up more memory and give more work to the garbage collector.

Actually, I do not understand how Translate function works? I think I use one more function in first one.