Out of left field & may not be truly appropriate to your piece [which we have no description of, as yet]
I learned to play at strict tempo back in the 80s… we suddenly got drum machines, after many years of playing in live bands with actual human drummers, who would ebb & flow with the rest of the band.
Drum machines are unforgiving.
You can make that vastly more unforgiving by putting a tempo-synced delay [echo] with a few distinct repeats on what you're playing. Play absolutely in time & your echo matches like a quantised sequencer.
Play badly & it sounds like a three-legged tinker's donkey running down a cobbled alleyway.
So, one way to learn to play in time is - work against a delay, over a drum machine. You will be able to hear immediately if you slip & slowly learn how to correct it as you play. You'll also discover whether you always speed & slow in the same places.
You don't need to record any of this, but it wouldn't hurt to be able to listen back afterwards.
This is cruel and unusual punishment when you're listening.
You will either learn fast or not at all.
Let me add one of my [hopefully] 'fun' anecdotes to this…
In 1983 we got our first chance to record an album of our own - after three years of hiding behind other names & sessioning for more well-known artists.
I'm not a great guitarist. I can get away with it but for this I decided to hire in an old friend I'd worked with a lot in previous bands, who was magnificent. He did some great work on the album, over a couple days in a residential studio in Scotland we had booked for the whole month.
Then, as we had him & his rig ready to go, it was decided one 'chug-a-chug' part which had been done on a synth on one of the demo tracks should be done with guitar instead.
...He just couldn't get it.
We were amazed. Patient, but amazed. This was a really great guitarist, but he'd never worked with a drum machine & echo before. We worked at it for an hour and it was not happening.
I stepped in instead [I really didn't want any hurt feelings - we liked the way this was going, but it needed to be tight].
It wasn't a 'difficult' part, it just required an absolute adherence to the tempo against a stereo echo running at 16s + 8s, left to right, for long periods of the track. "Tinker's donkey" was not an option.
I got the entire track in two takes. Here it is in all its very dated glory… chug-a-chug-a-chug, down the verses… [only the drum machine is sequenced, everything else is played, live. The 'marimba' & one of the chorus synths is also done on a similar echo.]
The album, btw, never recouped its own costs - such is life ;)