2014-04-09 15 views
7

Làm các bình luận chậm lại R?Làm các bình luận làm chậm R?

Câu hỏi này đã được hỏi hai lần trên StackOverflow về python:

Do comments slow down an interpreted language? Will excessive commenting of code slow execution?

Đối python câu trả lời dường như là 'không'. Tôi không biết đủ về sự khác biệt giữa hai ngôn ngữ để biết mức độ phù hợp của các câu trả lời đó cho R.

Đây là câu hỏi tương tự về khoảng trắng trong R. Một lần nữa câu trả lời dường như là 'không'.

does white space slow down processing

Trả lời

4

Đối với R câu trả lời dường như là 'có', trừ khi tôi đã làm sai ở đâu đó bên dưới.

# Time difference of 21.84725 secs 
# Time difference of 24.05738 secs 

# total.time.2 - total.time.1 
# 
# Time difference of 2.210126 secs 

n <- 280 

start.time.1 <- Sys.time() 

b <- 2 

for(i in 1:n) { 
    for(j in 1:n) { 
      for(k in 1:n) { 

       b <- b + 2 - 1 - 0.75 

      } 
    } 
} 

b 

end.time.1 <- Sys.time() 

total.time.1 <- end.time.1 - start.time.1 
total.time.1 


start.time.2 <- Sys.time() 

b <- 2 

# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 


for(i in 1:n) { 

# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 

    for(j in 1:n) { 

# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 

      for(k in 1:n) { 

# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 

       b <- b + 2 - 1 - 0.75 

# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 
# I wonder whether comments slow down R. Here are some comments. Let's see. 

      } 
    } 
} 

b 

end.time.2 <- Sys.time() 

total.time.2 <- end.time.2 - start.time.2 

total.time.1 
total.time.2 

total.time.2 - total.time.1 
+1

vâng, thực sự là ví dụ khi tạo gói, R xóa tất cả nhận xét.Đây là lý do tôi chưa bao giờ thấy hàm bên trong R (ví dụ: đưa 'ls' đến lời nhắc) có dòng nhận xét. –

Các vấn đề liên quan