Leave it to David Martin to cost-benefit analyze a chocolate milkshake.

“I’m an expert on chocolate shakes,” Martin declares from the Parkway Diner on High Ridge Road. It’s just past the afternoon rush and Martin isn’t having a shake, he’s drinking an iced tea.

“The diners, they vary a little bit,” he says. We’re still on shakes.

“They can be really good or they can be so-so. There’s a little more variation [at diners]. Whereas some other places, they’re always extremely good and extremely expensive, or they’re always very good and have better value.”

To open your mind to this way of thinking about dessert is to understand how Martin views the world. A chocolate milkshake is a delicious confection, of course, but it’s also a product to consider in terms of quality and price.

Take this idea and apply it to the mayor’s office and you’ll begin to get a sense of how Martin runs things at City Hall.

Stamford’s mayor since 2013, a post the 64-year-old won in a tight general election and even tighter Democratic primary race, Martin has approached his first term in office like a data analyst. He’s known for his granular charts and graphics.

“How much are we spending in resources and how much benefit is being generated? I want the benefit whether it’s in the dollars or services, and I want the benefit to exceed the cost,” Martin says. “A lot of people aren’t paying attention to that [in government]. If you’re in the private sector, they’re paying attention to that all the time.”

Martin would know. His time in office, if you don’t count his 20 years of volunteer service on the Board of Representatives, has yet to eclipse his time spent in the private sector finding ways to help companies run more efficiently. In the 1970s, after earning an MBA from Stanford University, he worked for Consolidated Rail Corp., an agency created by the federal government to turn around potentially profitable bankrupt rail carriers. Before becoming mayor, Martin was a partner in Michael Allen Co., a Darien consulting firm that advises pharmaceutical companies on their commercial operations.

Early in his term, Martin began emphasizing “performance metrics,” his way of introducing analytics to City Hall departments. “Results matter,” Martin told the Stamford Advocate in 2015, “and if results matter, you need to measure results. That’s the culture I want to promote.”

And what are the results? Martin will tell you government is running better than it has in decades. He points also to “financial integrity,” one of his most-used buzzwords. Under his watch, the city has begun to fully fund its future pension and retiree health care obligations. And there was an operating surplus last year of nearly $6 million.

“I’m not running this city in a way that will run it into the ground,” he says. “I’m going to make certain the stuff we do now does not set us up for failure 10 or 15 or 20 years from now.”

Martin’s second bid comes after a trying year in 2016. In February, he called a press conference to announce he was being treated for early-stage skin cancer on his left cheek. Meanwhile, his wife, Judy, had been fighting a private battle with cancer that claimed her life on Nov. 10, 2016. Her funeral service at Temple Beth El drew hundreds from the community where she was an elementary school teacher and founder of the youth mentorship organization, Starfish Connection.

The couple met at Conrail in Philadelphia and moved here in 1981 after Judy was offered a job at American Can Co. “[Stamford] offered professional growth, but it was also the diversity of this community that had welcomed us,” says Martin, who has two daughters with Judy, Rachel, 32, and Sarah, 29, whom the couple raised in a 3,400-square-foot contemporary on Long Ridge Road.

After his wife’s death, Martin would be in front of audiences when something stirred his memory, wetting his eyes.

Martin’s analytic bent doesn’t mean he’s shy about putting himself out there. When the Yerwood Center reopened its pool in May, Martin was the first to jump in during a press conference, a moment captured on Snapchat by his communications assistant. When promoting flu shots, he rolls up sleeves and takes the needle.

He has a background in science — he earned his bachelor’s degree in chemistry from MIT, which he says led to an affinity for the TV show “The Big Bang Theory” — and he’s also a musician. He played trumpet at his high school. Ever heard of Westbound Freight? You haven’t, because it was Martin’s rock band, which featured him on keys.

Martin grew up in Kansas City, Mo., raised by a mother who was a teacher and father who was a judge. He left for good after high school — now he might have less affection for a state that voted solidly for President Donald Trump, whom Martin isn’t shy about criticizing.

“I want to know what the truth is and how that impacts the decisions that we make, and that’s one of the big struggles ... ‘I heard this and that’ and people shouting at the top of their lungs because they wish something was true because it supports their conclusion,” he says.

This statement touches on Martin’s issues with Trump and also what he says frustrates him about his opponents.

Why is Martin the best candidate for mayor?

He pauses for a full minute to gather his thoughts.

“[Chief of staff] Michael Pollard was telling me, and a few others have said this as well — I surprise them. I surprise them because my engagement and energy is much higher than they would have expected and I surprise them because I’m putting most of my energy into policy and not [politics],” he said. “I surprise them because I’m looking for structural changes for problems that have taken a long time, and that’s hard.”

Editor’s note: Three candidates are vying to become Stamford’s next mayor on Tuesday — Democrat incumbent David Martin, Republican Barry Michelson and unaffiliated candidate John Zito. Each of them sat down for an interview with the Advocate ahead of the election to discuss their backgrounds and goals.