I'm having the same exact problem as the poster above me. Nexus 5 recently updated to 5.1, the phone reboots. Usually it optimizes all 140 apps, sometimes only approx. 50, sometimes less. This is usualy in a loop, but sometimes it boots succesfully. Additionally I am having problems with the wifi, which sometimes drops and refuses to connect. This is correlated with the reboots. I've tried factory reset and wipeing the cache, I'm now trying the WugFresh complete factory reset.
I'll update you if I have info, but I have a hunch this is hardware.
Tried everything, still the same problem. I'm assuming its hardware, so I'll probably return the device.