The very best gasoline engine, working
at peak efficiency, converts only 20 - 25 % of the thermal energy
available in gasoline to USABLE mechanical power. The rest goes
into waste heat. At partial loads and lower speeds, efficiency
CAN and DOES drop to as low as 12 % and waste heat increases proportionately.
A modern 4 cycle, direct injection diesel engine, on the other hand, at peak efficiency, converts 35 - 40% of the thermal energy of it's diesel fuel to USABLE mechanical power. At partial loads and lower speeds, diesel engine efficiency also falls off, but only to about 25 - 30 %.
Since all engines realistically always work at LESS than their MAX horsepower, MAX speed, MAX torque and MAX thermal efficiency, comparisons of actual diesel and gasoline engine operating efficiencies MUST be examined at partial load and power than MAX speed. It is understandable, then, why most diesel engines use 1/3 to 1/2 less fuel than any gasoline engine they replace. Or, stated another way, a diesel engine produces roughly twice the work and half the waste heat per gallon of fuel used than a comparably sized gas engine.
Diesels have always used at least 1/3 less fuel than typical gasoline engines. Long ago it was learned that actual constant load / constant speed gasoline and diesel engine horsepower could easily be determined by measuring the amount of fuel used per gallon -- 10 hp per gallon of gasoline consumed, 15 hp per gallon of diesel fuel consumed. Horsepower being the amount of work which can be done in a set time period. These approximations are still valid "rules of thumb" today for nearly full load applications; for partially loaded, the horsepower / gallons / hour difference is even greater.
As far as fuel efficiency is concerned, air cooled diesels will always outperform like-sized gasoline engines - by a factor of 50 - 100 %.