What factors affect how long it would take to get a phd, either going via, or without, a masters?
The answer, as oft seems true on this site, is that it depends. I'll lay out a couple things that might change how long a PhD might take, and where coming in with a Masters or Bachelors might change that.


Is there a large course sequence? And will your department accept previous coursework? If there's many classes to take at the graduate level and your PhD university accepts the classes from your Masters, having obtained an MS would likely trim the time from enrollment to PhD compared to a student with a bachelors degree starting at the same time. However, if the department doesn't accept those courses (and many good programs might not) then you're not necessarily all that far ahread.
Is it easier to get funding? If your department treats students who have not yet gotten their MS (in a sequence where the path from bachelors to PhD also involves getting an MS midstream) as transient and less likely to be funded, you might find yourself distracted and pulled in the direction of "rent needs to get paid" more than a better funded student.
Your Dissertation. Want to know what makes a PhD take X amount of time? By and large, its how fast your dissertation gets done. How quickly that happens has, in my experience, far more to do with how long a program takes then what letters you have after your name coming in.