The invention provides a quick and real-time electrocardiogram data compression algorithm suitable for low-power consumption systems, which can use fewer system resources to quickly compress the electrocardiogram data. The compression algorithm comprises the following steps of a, setting length N and calculation depth D of a data compression packet; if lossy compression is performed, setting lossycompression parameters; b, according to the calculation depth D, performing D-order differential operation on previous N data of an inputted data stream, so as to obtain a difference array, namely dev_1 to dev_N-D-1; c, sequencing the difference array, so as to obtain an array from small to large, namely a_1 to a_N, and a maximum value Max; d, if a section of which the value is not higher than Hbut is continuously smaller than K exists in the array, recording the position b of the starting value and number h of the section, and treating all data in the section as 0; e, setting the unit length of a bit stream of a result as n, and writing the difference values into the result in sequence; when the length is not enough, supplementing the lead to 0; f, setting the typical data structure ofthe compression packet as: head data |dev_1| to |dev_N|; g, after the setting of the bit stream is finished, respectively adding two-byte boundary markers at both ends.