This paper considers a real-time algorithm for performance optimization of switched-mode hybrid dynamical systems. The controlled parameter consists of the switching times between the modes, and the cost criterion has the form of the integral of a performance function defined on the system's state trajectory. The dynamic response functions (state equations) associated with the modes are not known in advance; rather, at each time t, they are estimated for all future times s t. A first-order algorithm is proposed and its behavior is analyzed in terms of its convergence rate. Finally, an example of a mobile robot tracking a moving target while avoiding obstacles is presented.