As the innings whizzed by, as the pitches accumulated, imagine what tortured Terry Collins had to be thinking as Steven Matz approached both Johan Santana territory and franchise immortality on Sunday.

The Long Island lefty didn’t end up tossing the second no-hitter in Mets history in a 5-1 win over the depleted Padres, dominantly carrying his bid into the eighth inning barely 50 months after Santana had finally put a stop to the Mets’ franchise-long, half-century run without one in June of 2012 against the Cardinals.

“Crap, here we go again,” Collins admitted saying to himself in the dugout around the fifth or sixth inning. “Had (Matz) got through the eighth inning, I was going to let him start the ninth, depending on what the eighth inning looked like.

“If he walked a couple guys and got up there pretty high, I wasn’t going to visit the Johan Santana scenario again, I can tell you that.”

As unabashedly emotional and heart-tugging a manager or coach as we’ve seen in New York as practically anyone you can name, Collins has ever-since agonized and remained haunted by that sell-your-soul night four years ago with Santana. He even once called the experience “without a doubt, the worst night I’ve ever spent in baseball.”

Santana, making just his 11th start after missing all of 2011 due to major shoulder surgery, never was the same pitcher after extending himself to throw 134 pitches that glorious night against St. Louis.

It turned out to be some tradeoff, however, for achieving that long-awaited piece of Mets history. The two-time former Cy Young winner went 3-7 with an ugly 8.27 ERA for the rest of that season and then never threw another pitch in the majors thereafter.

Steven Matz loses his no-hitter in the eighth, which takes the heat off Terry Collins.

(Jim McIsaac/Getty Images)

“Johan was different, Johan had just come off shoulder surgery. Little different story,” Collins said Sunday.

True enough. But Matz underwent Tommy John surgery earlier in his minor-league career and he’s pitched much of this year with a significant bone spur in his left elbow, which likely will require surgery in the winter. The 25-year-old also had been stretched to a season-high 120 pitches in his previous start.

The two-seamer that Alexei Ramirez lined just inside first base for the Padres’ first hit with one down in the eighth was No. 105 on the sweltering day for Matz. He’d still have had five outs to go if that ball had gone foul - or at least been ruled as such, like Carlos Beltran’s “foul ball” off the chalk past third during Santana’s gem.

Some of us in the press box even jokingly wondered if a torn Collins — to save himself from further agony and an impossible decision — actually would have argued for a hit had first-base ump Carlos Torres ruled that ball outside the foul line.

“Even though Steven had had the bone spur, I still, I can’t get away from it, because of my background in player development, I can’t stop looking at the big picture,” Collins said. “I’m not going to sacrifice this kid’s next year for one more inning, that all of a sudden, especially when you know he’s getting tired and that’s when injures are going to occur, when you start to get fatigued.

“So I wasn’t going to let that happen, but I didn’t have any particular number in mind that I was going to shut him down at, just going to read the situation.”

The way the Mets have been going, no hitter or not, they will take a win.

(Seth Wenig/AP)

The big-picture situation with the Mets, of course, is that they’ve been desperate for anything resembling a few doses of magic for weeks. Out of their injury-riddled team. Out of their prized young pitching staff. Out of Matz, who interestingly noted that he didn’t even have much of his family from eastern Long Island at the game because his parents were away on vacation.

Similarly, Collins gladly will pack his team’s first back-to-back victories since early July before jetting off to Arizona to kick off a 10-game swing fully believing his middling Mets still are in the playoff hunt — just 2.5 games out of the second NL wild card spot.

It mattered very little that the gutted Padres aren’t exactly a Who’s Who of big names at present, instead trotting out the kind of “Who’s He?” lineup almost begging to be on the wrong side of such history.

“I was hoping he was getting to the ninth inning with a no hitter,” Collins said finally, about Matz. “I wanted to see the energy in the crowd and I know how disappointed everybody is with what’s occurred this summer. But this is still a good team, expectations are still high, we’re still the National League champions, that’s never going to go away. The future is still here with (Jacob) deGrom and Matz and (Noah) Syndergaard, a healthy Matt Harvey and we have some kids coming.

“So I just said, boy, I hope he starts the ninth inning with a no-hitter. I’d like to see what happens.”

Honestly, what wound up happening probably was the best possible outcome for Collins, if not all involved.

After all, the Mets already have experienced all possible angles of what throwing a no-hitter can mean to a prized pitcher and the franchise. It’s not always all it’s cracked up to be.