यह कुछ सभी प्रोग्रामिंग भाषाओं के लिए आम है? प्रिंटल के बाद कई प्रिंट करना तेजी से लगता है लेकिन सब कुछ एक स्ट्रिंग में ले जा रहा है और केवल प्रिंटिंग जो सबसे तेज़ लगता है। क्यूं कर?क्यों इतनी धीमी गति से System.out.println है?
संपादित करें: उदाहरण के लिए, जावा सभी प्रमुख संख्या 1 लाख से ऊपर एक सेकंड से भी कम समय में प्राप्त कर सकते हैं - लेकिन फिर सब बाहर उनके खुद के println पर मुद्रण मिनट लग सकते हैं! मुद्रित करने के लिए 10 बिलियन घंटे तक!
पूर्व:
package sieveoferatosthenes;
public class Main {
public static void main(String[] args) {
int upTo = 10000000;
boolean primes[] = new boolean[upTo];
for(int b = 0; b < upTo; b++){
primes[b] = true;
}
primes[0] = false;
primes[1] = false;
int testing = 1;
while(testing <= Math.sqrt(upTo)){
testing ++;
int testingWith = testing;
if(primes[testing]){
while(testingWith < upTo){
testingWith = testingWith + testing;
if (testingWith >= upTo){
}
else{
primes[testingWith] = false;
}
}
}
}
for(int b = 2; b < upTo; b++){
if(primes[b]){
System.out.println(b);
}
}
}
}
व्याख्या करने के लिए देखभाल? मैंने हमेशा प्रिंटल को बहुत तेजी से पाया है ... – froadie
@ दासवुड "लगता है"? कृपया कुछ मानक (कोड + समय) प्रस्तुत करें। – NPE
यह विंडोज़ पर धीमी गति से * निक्स पर तेज़ हो जाता है। दूसरे शब्दों में, यह उन ओएस के कंसोल कार्यान्वयन है जो यहां कारक हैं। – skaffman