By default ls sorts the names, which can take a while if there are a lot of them. Also there will be no output until all of the names are read and sorted. Use the ls -f option to turn off sorting.
ls -f | wc -l
Note: This will also enable -a, so ., .., and other files starting with . will be counted.