Oil prices have been scorching hot this year. That rally has fueled big gains in most oil stocks, including shares of service companies Core Laboratories (NYSE:CLB) and Baker Hughes (NYSE:BKR), which have both rallied more than 10% so far this year.

That uptick in the oil market likely has investors wondering which company is the better one to buy right now. Here's a look at how they stack up.

Pump jack and engineer on a winter sunset sky background.

Image source: Getty Images.

Drilling down into the margins

While Baker Hughes and Core Labs both operate in the oil-field service sector, they're very different companies. Baker Hughes is a giant in the industry and is currently the third largest oil services company by revenue, behind Schlumberger and Halliburton. Core Labs, on the other hand, focuses on analyzing core samples and other data to help oil companies optimize the development of underground reservoirs. Because of their differences in size and scope, they don't make money the same way.

Baker Hughes provides a variety of specialized services to help oil companies find and extract oil and gas. The company not only needs to employ a large workforce to carry out these activities, but it must invest in equipment and buy consumable products like drill bits to complete work for its customers. These costs add up, which can weigh on margins, especially during challenging times in the oil market. When oil prices crashed during last year's fourth quarter, for instance, Baker Hughes' margins were in the low single digits.

Core Labs mainly does laboratory analysis, and thus it doesn't have to spend capital on expensive equipment. That's one reason Core earns the highest returns on invested capital in the oil-field service sector. In addition, this work carries higher margins, which tend to remain healthy even during tough times. That was the case in the most recently completed first quarter when Core's margins were 19%. Because Core earns high margins and doesn't need to invest much capital into its business, the company has consistently generated free cash flow. It recently notched its 70th straight quarter of producing free cash. Contrast this with Baker Hughes, which didn't produce any free cash in 2017.

Comparing their financial profiles

Since Core Labs doesn't need to invest much capital into buying new equipment, the company doesn't have a lot of debt. It ended the first quarter with about $295 million in debt. That's a very manageable level for a $3 billion company, especially one that consistently produces free cash flow.

Baker Hughes, on the other hand, ended last year with more than $7 billion in debt. While that's a manageable level for a $47 billion company, it's a much higher percentage of its total value compared to Core. That higher debt level is a concern since it could put pressure on the company's share price during periods of market turmoil.

A quick look at the valuations

While shares of both oil-field service companies are up double digits this year, Baker Hughes has surged nearly 20%, outperforming Core Labs' roughly 10% rally. The main factor holding back Core Labs was its lackluster second-quarter guidance, which recently caused its stock to slump 10%.

Shares of Core currently sell for 32 times expected earnings over the next 12 months. That's a higher forward earnings multiple than Baker Hughes' 25. However, it's harder to justify Baker Hughes' valuation than it is Core's since the later has very high margins and a top-tier balance sheet.

Verdict: Core Labs is the better buy

Core Labs' recent sell-off makes it a more compelling buy these days. Its valuation looks much more attractive considering that the company produces margins that wouldn't seem out of place in the technology sector and generates consistent free cash flow. Add to that a stronger balance sheet, and Core Labs seems like it has a better chance at outperforming Baker Hughes in the coming year, especially if oil prices cool off.

This article represents the opinion of the writer, who may disagree with the “official” recommendation position of a Motley Fool premium advisory service. We’re motley! Questioning an investing thesis -- even one of our own -- helps us all think critically about investing and make decisions that help us become smarter, happier, and richer.