performance - What runs faster in Ruby: defining the alias method or using alias_method? -


बाद में इनोकेशन पर क्या तेज़ है:

  def first_method? () Second_method? ()   

या

  alias_method: पहली विधि,: second_method   

और यदि संभव हो तो क्यों?

(नोट: मैं नहीं पूछता कि क्या अच्छा है / बेहतर आदि - & gt; केवल कच्ची गति और यह क्यों तेज है, यह दिलचस्प है यहां)

स्रोत कोड पर एक त्वरित नज़र, आपको चाल दिखाएगा:

alias_method को सी में लिखा गया है। रूबी में विधि जो दूसरे विधि को कॉल करती है, परिणामस्वरूप 2 विधि लुकअप और कॉल होंगे।

अतः, alias_method को तेज़ होना चाहिए।

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -