My idea is to do a project in Go and Ruby, to make a simple parse the same url to an rss feed, and check how long it takes each run of languages.
Let’s first talk about the project in Ruby .
We will have a class called
Parse::Rss , with some methods, as:
The main file, start the url variable with a value already set and start the Parse :: Rss class. initializing the class will already run parse the url and return the object that the gem returns.
url = "http://golangweekly.com/rss/1g2bo910" parserss = Parse::Rss.new(url)
Now is print the returns.
bundle install to install the gems of
$ bundle install
main.rb file return of the
Parse::Rss class and execution of time:
$ ruby main.rb The Title is: Go Newsletter The Description is: A weekly newsletter about the Go programming language The Link is: http://golangweekly.com/ The Categories is No have Categories The total of Items is: 4 0.360000 0.020000 0.380000 ( 4.406442)
Project on github: parserssrb
Now let’s talk about the project in Go .
As we have an external package, you will need to install using:
$ go get github.com/mmcdole/gofeed
Now create the file
parse/rss.go , in package
main.go in root path, this file we used time to calculate time run the project.
$ go run main.go Starting get The Title is: Go Newsletter The Description is: A weekly newsletter about the Go programming language The Link is: http://golangweekly.com/ The Categories is No have Categories The total of Items is: 4 Benchmark: 2.20670856s
Project on github: grfeed
In a quick comparison with the “same” functionality,
Go was faster than
Thanks! Until next time!