How does performance based pay for teachers work?

Let’s say you have 2 teachers in the same high school: Teacher A teaches Gifted and Talented English, has 60 students a day and Teacher B teaches general English and has 150 students a day.

Now will teacher A get more pay if her students score better than teacher B’s students on state testing?

I think that it is based on the progress of students. But I personally don’t think this would be fair to the Gifted teacher. How much more are they going to be able to learn? A lower student has more to grow.