These stocks beat the market when inflation is rising like it is now

The Labor Department said Tuesday that producer prices came in hotter than Wall Street expected last month. The big inflation report, the consumer price index, is out Wednesday and is expected to show a similar trend.

History tells us certain kinds of stocks thrive during inflationary environments.

Using hedge fund analytics tool Kensho, CNBC PRO found 32 periods going back to 1981 when CPI annual growth was between 2 and 3 percent. Here were the best and most consistent performers in the S&P 500 during those inflationary time periods (of varying time lengths).