# Optimizing Programs And Code them with Ruby way

**URL:** <https://www.ruby-forum.com/t/optimizing-programs-and-code-them-with-ruby-way/79828>\
**Category:** Ruby\
**Created:** [March 11, 2006, 11:08am UTC](https://www.ruby-forum.com/t/optimizing-programs-and-code-them-with-ruby-way/79828 "2006-03-11T11:08:52Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 11, 2006, 11:08am UTC](https://www.ruby-forum.com/t/optimizing-programs-and-code-them-with-ruby-way/79828/1 "2006-03-11T11:08:52Z")

</div>

Hi,

I am a newbie in Ruby. I wrote 2 small programs. Both are running with  
no errors.

For the first program it simulates a service queue in the variables  
musteri means customer and memur means worker of the bank. I would like  
to know how can i write it in Ruby way and more optimized.

For the second one i try to read system process table log it and then  
try to point programs which are using a lot of cpu and kill them. I use  
ps and awk except Ruby. I would like to know how can i do it with pure  
Ruby (without ps and awk ) and also with Ruby way. Thanks for all  
answers

ps: Comments of the code are in turkish but i suppose codes is enough  
for you. If it will be a problem i can translate them into english.

Serbulent UNSAL

1. [Serbülent Ünsal'ın Web Günlüğü: ...Ruby](http://nightwalkers.blogspot.com/2006/03/ruby.html)

2. [Serbülent Ünsal'ın Web Günlüğü: ...Ruby Bölüm 2](http://nightwalkers.blogspot.com/2006/03/ruby-blm-2.html)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 12, 2006, 1:10am UTC](https://www.ruby-forum.com/t/optimizing-programs-and-code-them-with-ruby-way/79828/2 "2006-03-12T01:10:49Z")

</div>

removed\_email\_address@domain.invalid wrote:

> Hi,
> 
> I am a newbie in Ruby. I wrote 2 small programs. Both are running with  
> no errors.
> 
> For the first program it simulates a service queue in the variables  
> musteri means customer and memur means worker of the bank. I would like  
> to know how can i write it in Ruby way and more optimized.

Have you tried running it with ‘ruby -rprofile’?

> 1. [Serbülent Ünsal'ın Web Günlüğü: ...Ruby](http://nightwalkers.blogspot.com/2006/03/ruby.html)
> 
> 2. [http://nightwalkers.blogspot.com/2006/03/ruby-blm-2.html](http://nightwalkers.blogspot.com/2006/03/ruby-blm-2.html)

Mike
