There's two problems here; the theoretical maximum and the humanly feasible maximum. For the theoretical max, check the "Food per hour" metric on the Treat Farms wiki page. It also shows you the cost per food; note that the longer the grow time, the less efficient the food/hour and food/money metrics get.
The cheapest foods actually produce the most food in the least time and for the least cost (an exception below). However, it's not humanly possible to sit at the game and harvest Dragonsnaps every 30 seconds.
Instead you should just plan your food growing based on how long you'll be away from your game. When you start out, you'll probably be playing actively and pick very quick-growing food. As time goes on you'll check the game less and prefer Pumpermellons for the 8 hour time; if you only check the game once every 8 hours, Pumpermellons are suddenly the most efficient.
Also remember to always build a new treat farm immediately when you can at level up; you can even buy the cheapest one and upgrade later. Since there's no build time, buy the cheapest one you can afford, as it still lets you farm more. Every level up, check and see if you can build another treat farm.
There's a late game exception however; once you upgrade your farms a second time to the Huge Treat Farm, you get very high-cost, short grow time treats. These foods all grow in an hour or less, and cost exactly 50 gold per food and give large volumes of food in very stort times. It's basically converting your money straight into food, bypassing (most) of the growing time problem. These are the least cost efficient, but once you have millions of Cash, you'll prefer it to manually growing all the time.
EDIT
With the race being put into the game this could not be a much better way to change Gold into XP. The race will always cost you 50,000 gold and the reward is random, but hitting even 1.8m in a reward out of 20 tries would average the results of breeding metal dragons listed below. However, I am going to leave the information below as well because there is nothing saying you can not breed metal dragons while running races.
Based on the data I could find, raising dragons is the best gold to xp exchange granting a 4 to 1 ratio for Earth dragons and a 2 to 1 ratio for Fire and Metal dragons.
Behold, a chart! (Created with v1.7.2 data)
The above ratios assume you are not keeping the dragon and are going to sell the dragon as soon as it hatches. It also only contains dragons that can, at this point in time, be purchased directly for gold and raised.
There may be some long game plan you could do with raising farms to raise dragon levels but there is not currently enough information available for me to crunch those numbers to see if it is more efficient to sell a higher level dragon vs the food costs to get it there.
One last note selling and buying dragons every 5 minutes is not the least tedious thing to be doing, but it does cycle through your hatchery pretty well depending on what types of dragons you are attempting to breed.
Best Answer
Per the DragonVale wiki:
Some tips to make best use of this ability: