Much like moving through difficult terrain, it costs 1 extra foot of movement for every foot spent moving while swimming. Worse, if a creature is moving in difficult terrain, this movement instead costs 2 extra feet of movement for every foot spent for a total of 3.
For example, a rogue with 30 feet of movement speed would only move 15 feet on their turn while trying to swim across a river. Should that same rogue try swimming that same distance when there are rapids present, however, they would instead move only 10 feet.
If a creature has an innate Swimming speed listed in their stat block, they move at the listed speed while Swimming without having to spend any additional movement, unless moving through difficult terrain.
At the DM’s option, gaining any distance in rough water while swimming might require a successful Strength (Athletics) check.