1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
require 'rubygems' require 'data_mapper' require 'benchmark' DataMapper::Database.setup({ :adapter => 'sqlite3', :database => 'perf_dm.db' }) # set up DataMapper class DmItem include DataMapper::Persistence set_table_name 'items' property :name, :string property :description, :text property :active, :boolean property :created_at, :datetime end database.save(DmItem) # DataMapper::Persistence.auto_migrate! 1000.times do |i| x = DmItem.new(:name => "record_#{i}", :description => "test record", :active => i.remainder(3).zero?) x.save end # run benchmarks Benchmark.bmbm do |x| x.report('DataMapper single-thread') do 100.times do DmItem.all(:active => false) end end x.report('DataMapper threaded') do threads = [] 10.times do t = Thread.new do 10.times do DmItem.all(:active => false) end end threads.push(t) end threads.each { |t| t.join } end end
Refactorings
No refactoring yet !
Sam Smoot
February 20, 2008, February 20, 2008 21:03, permalink
Basically I've done some dumb things around 0.2.5 onward. ;-) Been focused on bug-hunting.
An easy performance tweak would be to wrap your benches in a database { } block though so you get a boost from a shared IdentityMap.
Regardless, I expect DM to be the fastest Ruby O/RM by MWRC with the 0.9.0 release. :-D
Another minor note though: DM doesn't have a non-threaded version, and it doesn't use threads internally. It just mutexes by default where it needs to to make it thread-safe. Non-blocking threads and epoll with Rev or EventMachine are ideas being tossed around for a post 1.0 release, but that's probably a few months away at least at this point.
1 2 3 4 5 6
# Of course this is cheating... ;-) database do 10.times do DmItem.all end end
Sam Smoot
June 11, 2008, June 11, 2008 21:20, permalink
Updated to DM 0.9.x syntax.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
#! /usr/bin/env ruby require 'rubygems' gem 'dm-core', '>=0.9.1' require 'dm-core' require 'benchmark' DataMapper::setup(:default, "sqlite3:///#{Dir.pwd}/perf_dm.db") # set up DataMapper class DmItem include DataMapper::Resource storage_names[:default] = 'items' property :id, Integer, :serial => true property :name, String property :description, Text property :active, Boolean property :created_at, DateTime end DmItem.auto_migrate! 1000.times do |i| DmItem.create(:name => "record_#{i}", :description => "test record", :active => i.remainder(3).zero?) end # run benchmarks Benchmark.bmbm do |x| x.report('DataMapper single-thread') do 100.times do DmItem.all(:active => false) end end x.report('DataMapper threaded') do threads = [] 10.times do t = Thread.new do # Assuming that we're using a thread like a threaded-request in Merb, # we'll scope the repository block to just an individual thread. repository(:default) do 10.times do DmItem.all(:active => false) end end end threads.push(t) end threads.each { |t| t.join } end end __END__ Rehearsal ------------------------------------------------------------ DataMapper single-thread 0.010000 0.000000 0.010000 ( 0.012696) DataMapper threaded 0.020000 0.000000 0.020000 ( 0.013543) --------------------------------------------------- total: 0.030000sec user system total real DataMapper single-thread 0.010000 0.000000 0.010000 ( 0.013356) DataMapper threaded 0.010000 0.000000 0.010000 ( 0.013338)
Sam Smoot
June 11, 2008, June 11, 2008 21:27, permalink
Oops. My bad. Forgot to add the kicker methods (Enumerable#entries) so the previous run wasn't actually executing the SELECT queries.
So as promised, the new DM is over twice as fast as AR. :-)
And thread-safety is not optional in DM. ;-)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
#! /usr/bin/env ruby require 'rubygems' gem 'dm-core', '>=0.9.1' require 'dm-core' require 'benchmark' DataMapper::setup(:default, "sqlite3:///#{Dir.pwd}/perf_dm.db") # set up DataMapper class DmItem include DataMapper::Resource storage_names[:default] = 'items' property :id, Integer, :serial => true property :name, String property :description, Text property :active, Boolean property :created_at, DateTime end DmItem.auto_migrate! 1000.times do |i| DmItem.create(:name => "record_#{i}", :description => "test record", :active => i.remainder(3).zero?) end # run benchmarks Benchmark.bmbm do |x| x.report('DataMapper single-thread') do 100.times do DmItem.all(:active => false).entries end end x.report('DataMapper threaded') do threads = [] 10.times do t = Thread.new do # Assuming that we're using a thread like a threaded-request in Merb, # we'll scope the repository block to just an individual thread. repository(:default) do 10.times do DmItem.all(:active => false).entries end end end threads.push(t) end threads.each { |t| t.join } end end __END__ ~/src > ./datamapper-threaded-benchmark.rb Rehearsal ------------------------------------------------------------ DataMapper single-thread 4.640000 0.020000 4.660000 ( 4.665218) DataMapper threaded 1.370000 0.020000 1.390000 ( 1.391590) --------------------------------------------------- total: 6.050000sec user system total real DataMapper single-thread 4.670000 0.020000 4.690000 ( 4.683495) DataMapper threaded 1.350000 0.010000 1.360000 ( 1.368878) And just for comparison, on the same machine: ~/src > ./activerecord-threaded-benchmark.rb == NewItem: migrating ======================================================== -- create_table(:items) -> 0.1062s == NewItem: migrated (0.1063s) =============================================== Rehearsal --------------------------------------------------------------- active_record single-thread 8.350000 0.030000 8.380000 ( 8.393329) active_record threaded 9.760000 0.060000 9.820000 ( 9.828526) ----------------------------------------------------- total: 18.200000sec user system total real active_record single-thread 8.340000 0.050000 8.390000 ( 8.404241) active_record threaded 9.720000 0.060000 9.780000 ( 9.772168) == NewItem: reverting ======================================================== -- drop_table(:items) -> 0.0020s == NewItem: reverted (0.0021s) ===============================================
saitousesyday
July 16, 2010, July 16, 2010 23:31, permalink
Hi, Is there anybody here?.
I like refactormycode.com because I learned a lot here. Now it's time for me to pay back.
The reason I want to post this guide on this of refactormycode.com is to help visitors solve the same problem.
Please let me know if it is unacceptable here.
This is the guide, wish it would do people a favor.
How to convert DVD to iPod, convert AVI/ WMV/ MPG/ MPEG/ MOV/ DAT/ ASF/ RM/ RMVB to iPod and update video to your ipod through iTune
Nowadays, most iPod converter is popular more and more going with iPod developed. This guide is write for users to recommend a tool (Wondershare iPod Video Suite). Wishing it is useful to you.
Before you convert your files, please know the general limits which the iPod carry .
H.264 video: up to 768 Kbps, 320x240, 30 frames per sec., Baseline Profile up to Level 1.3 with AAC-LC up to 128 Kbps, 48 KHz, stereo audio in .m4v, .mp4 and .mov file formats.
MPEG-4 video: up to 2500 Kbps, 480x320, 30 frames per sec., Baseline Profile up to Level 1.3 with AAC-LC up to 128 Kbps, 48 KHz, stereo audio in .m4v, .mp4 and .mov file formats.
I. How to convert DVD to iPod with Wondershare DVD to iPod Ripper (for windows)
Features:
Wondershare DVD to iPod Ripper can convert / rip DVD to iPod video directly (needn't convert DVD to AVI or VOB first)
If you're a Windows user, Wondershare DVD to iPod Ripper works great for you. You can convert/rip DVD to iPod Video easily. Additional, its rich options and conversion quality can satisfy your entire requirements. After testing, all formats to iPod conversion works well! Let's view the steps.
You can download the latest version Wondershare iPod Video Suite . Then install and run it.
Then Click "DVD to iPod Converter(, ) component" to open the DVD to iPod Ripper
Step1.Import DVD files
1) Rip your DVD files from DVD-ROM drive by clicking ?Open DVD?.
Many friends asked how to copy movies form DVDs to pc. This process calls ?Rip?. Additional, rip DVDs is illegal. This software helps you rip DVDs automatically. You needn?t know how to break the css protect. I really love this function.
2) Or Load .ifo files from your hard disk by clicking ?Add ifo?.
3) Or right click on the blank area in the center of the main interface to import video files from your hard disk or DVD-ROM drive.
Step2: select subtitle, audio and output format
1) Regular DVD movie usually has several subtitles, like English, French, German, etc. You can select anyone according to your need.
2) Select Audio it the same as select Subtitle.
3) Format: this software can convert DVD to MP4 format which are fit for iPod player, it also can extract audio track from DVD and save as MP3 or M4A format which are fit for any other MP3 player.
Step3: Start Convert
After all the things done, click the ?start? button to start the conversion. Then a window will be popped up.
Here you can preview your DVD when converting the DVD. There also has an important option name ? Directly transport video files to iPod after conversion ?. If you check it, then when finish conversion and your iPod has connected to PC well, the MP4 files will be transported to iPod directly; you needn?t drag them to iTunes then sync your iPod. It?s really useful for the people who know little about iTunes? complicate operation.
Tips
Tips.1 Click the option button, a window will be popped up. Here you can set resolution, frame rate, width/length ration, video bitrate, codec, conversion speed, sample rate, audio channels and audio bitrate. Here are some tips about the options.
1. Resolution: iPod?s resolution is 320*240.
2. Frame rate: 25fps is PAL, 30fps is NTSC.
3. Length/Width ration: 4:3 is common display; 16:9 is width screen display.
4. For ?Codec? setting. There are two choice for you ? ?H.264? & ?xVID?.? H.264? provides higher quality with less file size. But the conversion time is longer than ?xVID?. If you care about the video definition. ?H.264? would be your choice. I prefer ?xVID? to ?H.264?. Because it?s difficult to distinguish the difference between ?H.264? and ?xVID? on iPod?s little screen.
5. Video bitrate and audio bitrate: higher bitrate provides better quality with lager size and longer conversion time.
Tips.2 DVD movie often has a black border on both the top and bottom, if you want to cut it and watch your DVD with full screen; you can click the ? cropping ? button. Then a window will be popped up, on this window, you can drag the yellow frame to cut any parts you don?t want when you preview the DVD movie, or you can use the crop window which set in advanced on the top of the window.
Tips.3 Click the ?effect? button; you can set the Brightness, Contrast, Saturation and Audio volume for the DVD movie.
Tips.4 In the default setting, this software convert your DVD into one files with all chapters, if you just want to convert some chapters of the DVD, you can click the ?Show chapters? button, then check the box before the chapters you want to convert.
Tips.5 If you just want to convert some parts of the DVD, you can drag the scroll bar below the preview window to set the conversion start and end time, or you can click the ?trim? button to set it exactly.
Tip.6 DVD player is combined with this software, after you add the DVD files, you can click the ?Play? button to preview your movie, if you double click on the preview window, and you can also watch your movie in full screen model.
II. How to convert AVI/WMV/MPG/MPEG/MOV/DAT/ASF/RM/RMVB to iPod with Wondershare Video to iPod Converter(, ) (for windows)
Wondershare Video to iPod Converter(, ) can convert AVI/WMV/MPG/MPEG/MOV/DAT/ASF/RM/RMVB to iPod video directly. If you're a Windows user, Wondershare Video to iPod Converter(, ) works great for you. You can convert all popular video formats to mp4 easily. After testing, all formats to iPod conversion works well!
After installing the Wondershare iPod Video Suite . Click 'Video to iPod Converter(, )' button to lunch it. Its interface and operation are similar to DVD to iPod Ripper.
But compare with DVD to iPod Ripper, there are two parts that are emphasized:
1. In DVD to iPod Ripper, you click the option icon on the top to open the option window. In Video to iPod Converter(, ), you can right click the video files and click Params Setting to open the option windows. This function let you set different options to different tasks . For example, you set the conversion format for the first video in xVID, and you can set it for the second video in H.264. So you can import multi files at one time and set the suitable option for each task and then go away to do any other thing. It?s really good, I love it.
2. With Video to iPod Converter(, ), you can capture any lovely pictures from the videos. Either be your cool desktop or print it. There is a small camera icon on the right part of the interface. Click it while previewing the video; it will save the current picture of the video for you. More over you can save it in .JPG or .BMP.
3. This software embeds an iPod file manager, with it; you can easily copy or transfer video, movie, TV show or songs between iPod and Computer.
Click the iPod file manager icon on top of the main interface and open it, the left part is your video on computer, the right part is your iPod video files. For example, if you want to copy files from iPod to computer, check the box before the files on the right part, then click ?left arrow?, your files will be transferred from iPod to PC automatically. Transfer files from PC to iPod is the same, you can easily manage it.
Operations
Step 1 . Import video files by clicking ?Add files? or right click the blank of the main interface to ?Load Videos??
Step 2 . Option setting. It?s the same as ?DVD to iPod Ripper?. So I?m not repeating it. You can refer above details to manage it.
Step 3 . Select output directory. The default out put directory is C:Program FilesWondershareiPod Video Suitevideo2ipodOutput
Step 4 . Go, Go, Go. Click ?Start? button to start the conversion.
III. How to update video to your ipod through iTune
Step.1 Connect your iPod to PC, launch iTunes.If you don?t have iTunes. You can download free from here:http://www.apple.com/itunes/affiliates/download/ We recommend that you create a new list to place the file you converted.
Step.2 Find the mp4 file you have converted, directly drag into the playlist you created just now.If you have added the file to the library of the iTunes, you can drag it from library to the new playlist directly.
Step.3 Update your iPod. Click ?File?->?update your iPod?.After updating, you can see the file list on your ipod. You can change the file name showing on iPod. Please right click the file, choose "Get info", and change the info of this file at "Info". You are done and enjoy!
howtomeetagirlhv
July 17, 2010, July 17, 2010 21:58, permalink
Hey guys I'm not persuaded if this is the right space to mail this, but I am having some legitimate grieve learning meet girl I read meet girl that site, but it in actuality didn't seem to give to me alot of substance to me. Can someone pretty please improve me? It's so exhausting to convene the girls of my dreams.
kopele1
July 27, 2010, July 27, 2010 14:28, permalink
Hello guys. I'm making my first website and I want to put some flash videos. I searched Google and I found some sites but none is understandable enough for a beginner like me… I can't understand anything since I don't have any experience with html/php coding… so if any of you knows a good place with information for beginners please share! Thanks.
businesscardonlineqa
Yesterday, July 28, 2010 13:51, permalink
Your business card online is an extension of your firm and is important for product branding. It reflects your operation profile, your products and services and is most suitable for marketing likewise as networking. A well planned business card online can make a lasting primary impression, that is crucial if you ever do not want your business card thrown away. At Pixellogo, we deliver online ingenious model solutions which are significant whilst branding your firm image. Browse by way of our stationery catalogue and pick customizable style templates or use our artwork solutions to exclusively structure your personal business card. Whether that you're a little start-up business organisation or an previously established business, you will be able to get your perfect business card model on this website.
Pioneering models for the business card online! Make the most beneficial use of our business card online solutions
We make business card online patterns to fit your company’s requirements, but which convey your organization profile in an attention-grabbing way. You will find styles suiting each business will need ranging in the food sector into the sports sector the following! We offer ready-to-use business card online templates which you're able to download and modify as per your requirements. We also provide exclusive design that will reflect your lender persona from the most specialized way. You possibly can website design a business card online by collaborating with our business card maker, who will endow you with a selection of design you might decide on from. If you ever approve of any style and design but would like it being modified, our business card online maker will alter it for zero cost! We even add style fx for your cards to produce them a great deal more catchy. So what have you been waiting for!? Produce your eye-catching business cards online, ideal right here on our site.
make business card
print business cards online
business cards program
professional business cards
business cards legal
metal business cards
business card printing online
design business card online
cool business card design
free business card maker
business card program
free business card designs
business card designs
free business card creator
design your own business card
designs business cards
premium business cards
unique business cards
business card ideas
make your own business card
third of three - slowest of those tested, even though it's thread-safe - why?