This paper presents a method to evaluate the computational cost of a function in embedded systems. This method, which uses the Least Squares method, is useful to see the sample time choice feasibility, in control applications. In this work, the developed method is used to evaluate the computational cost of the model-based predictive control to speed control of a shunt direct current motor. The method was tested using two embedded devices allowing to find the correct sample time for each device evaluated.