Very slow frame rate in Xcode

I’ve recently started a course in OF and when I add a piece of code that resets the position of objects to the update function the whole animation has about 1 fps and it takes 140% from my 16GB CPU.
Any help?

Using a 15 inch 2017 Macbook
2,9GHz Intel Core I7
Radeon Pro 560

I found the problem. I was using ofGetScreenWidth() in my update. Made a global float instead and it works fine now.