The invention is directed to methods and devices for optimization of biventricular pacing in subjects suffering from heart failure. The invention provides for a method for selection of optimal parameters for permanent pacing, the method comprising: positioning one or more arrays of lead wires in the posterior pericardium of a subject, wherein the arrays are connected to a multiplexing switch, wherein the switch is connected to a computer processor and a biventricular pacemaker; from the computer processor, generating a randomized sequence of: (i) pacing sites (VPS), (ii) right ventricular-left ventricular delays (RLDs), (iii) heart rates (HR); (iv) atrioventricular delays (AVDs), (v) or any combination or permutation thereof; and determining cardiac output in real time, using aortic flow velocity, thereby allowing selection of optimal parameters for permanent pacing.