I'd say not very easily - you could replicate the unit you want (I think the gamecache Store Unit function can create an exact copy with items/abilities intact) and order it to attack a pre-placed magic immune target dummy (one for each player) - then, when <dummy> takes damage, and BooleanVar[Player number] = false, start a timer and set BooleanVar to true.
When the dummy takes damage again (check if BooleanVar[Player number] is true), set a real variable to GetElapsedTime (YourTimerVar), remove the replicated unit, set BooleanVar[Player number] to false again, and display the value of the real variable to the player.
Also, make sure that you can't activate the trigger more than once every X seconds, so people can't create a second testing unit, which would obviously screw up your results (easiest way would probably be to check if BooleanVar[Player number of Triggering Player <assuming you're using a chat command, or Escape key>] is true or false - if true, don't do the test (since it's already running), else do the test)
I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
I'm on a page about incorrect corrections, and spent the better part of like two hours trying to get someone to understand that -5^2 = -25, not 25, and then that post had comments get reposted because that group is self sustaining, and that person was in turn trying to explain what I just explained to them. And I'm taking that as a victory