From a 'ideal' thermodynamic cycle perspective, gasoline engine is more efficient. But in practice diesel engine benefits from less (or zero ) gas-exchange pumping losses (significant in part load operation) and lower coolant thermal losses. In general, these factors (in addition to the higher compression ratio) makes it more efficient.
The optimal compression ratio from an efficiency point is around 16-18:1, at higher CR the benefits are small and thermal and other losses increase.
In gasoline engine, the compression ratio is limited by knocking at higher loads.
The efficiency of gasoline engines at partial loads has been limited by throttling, as they can operate only at certain ranges of the air-fuel ratio. One of the ways around this is to run the engine in a "diesel mode" (HCCI).
If we used same compression ratio then gasoline engine would be effective. As in common use we see that diesel have high efficiency but it is operating at high compression ratio as compared to the gasoline engine. If we reduce the compression ratio of diesel engine equal to the gasoline engine then we can see that efficiency of gasoline engine is more then that of diesel engine.