Answer to

old chestnut: 15 wires:

He only needs to walk the length of the building twice.

First, he ties together the ends of the wires at the end where he is now
into five groups: one with five wires, one with four, one with three,
one with two, and one wire alone.

Next, he goes to the other end of the building and tests the continuity of
many pairs to determine which ends there are part of each group. He labels
them, for instance, 5A, 5B, 5C, 5D, 5E for the five wires that were tied
together at the other end. Then, before he leaves this end, he ties together
all the As, all the Bs, etc. -- each bundle contains wires from different
bundles at the other end.

Back at the first end, now he unties these ends but labels them as to which
group (1, 2, 3, 4, or 5) they were part of. He then uses the tester to
determine which group (A, B, C, D, E) each wire is now part of at the other
end, and by combining these two bits of information he can put the correct
labels on the wires at this end.

If he needs to restore the wires to their original, unconnected state he'll
need to make another trip to the other end to untie them.