Do you know what I'm talking about?
Why do I need to ask? You've counted sheep before! We all have.
Laid in bed. Wide awake. The hours slowly drifting by, the Little Big Ben ticking away. It's luminous dial much too bright! Six o'clock getting nearer and nearer. It's three a.m. and you only have three hours left before you have to get up and go to work.
You toss. You turn. You can't fall asleep. An endless series of white identical sheep, black hoofs, black noses, black eyes. They jump over a fence. One, two, a white picket fence, three. You count. Four, Five, Six. They start looking at you, Seven, Eight, Nine, laughing, Baa ha ha. 10, 11, 12, Baa ha ha, 16, 32, 64, 128, and so on and so on. You can't get the visuals out of your head. All identical, 712, 844, 845. Jumping, 901. Baa ha ha-ing! Over the fence. One after the other.
Six o'clock arrives and you get up, tired. You go to work.
You were counting sheep!
What were you trying to do by Counting Sheep?
What you actually tried to do was make yourself so bored, by the repetition of sheep jumping over a fence that it would lull you to sleep. Sometimes it worked! Especially, if you are the suggestive type.
The practice is stereotypical and only used personally as a notion in pop culture of the idea, an idiomatic term for needing sleep.
A doctor would not prescribe "Counting Sheep" as a solution for insomnia.
Which leads me into another blog. Burning the Candles at both ends another idiom.