Input AC current of a mains power supply - how is defined
Power factor is the ratio of the real power divided by the product of the RMS voltage and the RMS current.

Think about what that says.  Note that real power is NOT just the voltage times the current, each measured separately.  Let's say you have a device and you want to know how much power it draws.  You put a voltmeter across its input and get 115 V AC.  Then you switch to a current scale, put the meter in series, and measure 300 mA AC.  At first glance, you might think that the power is (115 V)(300 mA) = 34.5 W, but it turns out that's just the upper limit.  The real power can be anything from that down to 0.

How can this be?  Imagine if the device is a capacitor.  In that case the voltage and current are 90&deg; out of phase.  During half the cycle, the product of the instantaneous voltage and instantaneous current is positive, and real power is being transferred into the device.  However, over the next half cycle that product is negative, and the same power is transferred back out again.  Over a whole cycle, the net power averages to 0.

On the other hand, if the device is a resistor, the voltage and current are always proportional to each other.  In the case of a resistor, it really is receiving 34.5 W from the AC line, and will get hot accordingly.

In the case of pure sine waves only, you can look at the phase angle between voltage and current to get some idea of what fraction of the maximum possible power is actually being transferred.  However, many real world device don't cooperate and draw current in nice sine waves.  We need a more general way to measure this "fraction of max power you actually get".

The general way is to do just that.  The max power you can get is the RMS voltage times the RMS current.  We'll normalize to that and call it 1.0.  The actual power will therefore be between 0 and 1.0 on this normalized scale.  That is exactly what power factor is.

So how do you measure real power?  Power is voltage times current, but you can't average the voltage and current before the product.  To get the real power, you have to multiply the instantaneous voltage and current, then average.

This is exactly what real power meters do.  The old mechanical electric meters with the rotating disk by the corner of your house work on the principle that the magnetic force between two electro-magnets is the product of the current thru each.  This actually works in all four quadrants.  If the two currents have the same polarity, the electromagnets attract.  If the polarity of one gets flipped, then they repel.

The ability of electromagnets to perform a four-quadrant multiply is harnessed by driving one with the voltage, the other with the current, then using them to implement a motor.  The force driving the motor in any one instance is the current times the voltage.  This is averaged out by the mechanics of the motor.  It is effectively integrated by keeping track of the total number of turns of the motor, not just the instantaneous speed.  The various dials on the electric meter are just the motor geared down, each by a factor of 10 from the previous.  The digits pointed to by each dial then show the total turns of the motor, which is the total energy the meter has seen pass.  By subtracting the current reading from last month's reading, the power company knows how much energy you used that month, and therefore how much to bill you.

Modern electric meters use microcontrollers that read the instantaneous voltage and current many times during a power line cycle.  Each reading pair is multiplied to get the instantaneous power, then accumulated to get the total energy.  To not get fooled by very spiky current, you need to do a pretty good job of measuring the first 100 or so harmonics at least.  That means for 60 Hz power, you want to resolve at least 6 kHz components.  Fortunately, modern microcontrollers can do well past that rather easily.