Wireless Body Sensor Networks (WBSN) are poised to become a key enabling technology of personal systems for pervasive healthcare. Recent results have however shown that the conventional approach to their design, which consists in continuous wireless streaming of the sensed data to a central data collector, is unsustainable in terms of network lifetime and autonomy. Furthermore, it was established that wireless data communication is responsible for most of the energy consumption. To address the energy inefficiency of conventional WBSNs, we advocate an advanced WBSN concept where sensor nodes exploit their available, yet limited processing and storage resources to deploy advanced embedded intelligence and processing, to reduce the amount of wireless data communication and consequently energy consumption. More specifically, this paper addresses the design and optimization of an automated real-time electrocardiogram (ECG) signal analysis and cardiovascular arrhythmia diagnosis application for a prototype sensor node called Wireless 25 EEG/ECG system. The satifactory accuracy of this on-line automated ECG-based analysis and diagnosis system is assessed and compared to the salient off-line automated ECG analysis algorithms. More importantly, our results show an energy consumption reduction of 80% to 100% with respect to conventional WBSNs, when our analysis and diagnosis algorithm is used to process the sensed ECG data to extract its relevant features, which are then wirelessly reported to the WBSN central data collector, after the node can automatically determine the potential cardiovascular pathology without human monitoring.