3. As shown in Figure 1, the side length of square $ABCD$ is 4 units. A moving point $P$ starts from point $A$ and moves counterclockwise along the boundary of the square, advancing 5 units and then retreating 3 units. It is known that point $P$ moves forward or backward 1 unit per second. Let $x_{n}$ represent the distance between point $P$ and $A$ at the $n$-th second. Then $x_{2012}$ is ( ).
(A) $\sqrt{17}$
(B) $2 \sqrt{5}$
(C) 5
(D) $4 \sqrt{2}$
3. B.

Notice that, $2012=8 \times 251+4$.
Therefore, point $P$ moves counterclockwise from $A$ for 2012 seconds, covering a total of $2 \times 251+4=506$ units.

And $506=4 \times 4 \times 31+4 \times 2+2$, so point $P$ moves counterclockwise 31 full circles and reaches the midpoint of side $C D$.
Thus, $A P=2 \sqrt{5}$.