# Ruby Filter : difference between init option and path option in terms of performance

**URL:** <https://discuss.elastic.co/t/ruby-filter-difference-between-init-option-and-path-option-in-terms-of-performance/323677>\
**Category:** Logstash\
**Created:** [January 22, 2023, 1:27pm UTC](https://discuss.elastic.co/t/ruby-filter-difference-between-init-option-and-path-option-in-terms-of-performance/323677 "2023-01-22T13:27:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mostafaelsayed](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mostafaelsayed/32/82057_2.png) [@mostafaelsayed](https://discuss.elastic.co/u/mostafaelsayed)\
**Post date:** [January 22, 2023, 1:27pm UTC](https://discuss.elastic.co/t/ruby-filter-difference-between-init-option-and-path-option-in-terms-of-performance/323677/1 "2023-01-22T13:27:07Z")

</div>

Hello All,

while I am reading on Ruby filter plugin, I found that the "init" option is used to execute any code at startup time.

so, is there any 'performance' difference between path option and init option used like the 2 examples below:

using path option:

```auto
filter {
    ruby {
          path=> "set_data_1.rb"
      }
      ruby {
          path=> "set_data_2.rb"
      }
}

```

using init option

```auto
filter {
    ruby {
        # utils.rb contains the methods set_data_1 and set_data_2
        # so they can be used directly in later ruby filters
        init => "require Dir.pwd + '/utils.rb'"
        code => "puts ''"
    }
   ruby {
       code => "
         set_data_1(event)
         set_data_2(event)
        "
   }
}

```

Thanks

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 19, 2023, 1:27pm UTC](https://discuss.elastic.co/t/ruby-filter-difference-between-init-option-and-path-option-in-terms-of-performance/323677/2 "2023-02-19T13:27:57Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
