The document discusses using Foreign Function Interface (FFI) to extend Ruby with C code. It describes defining a C struct for metrics similar to a Ruby Metric class, then binding the C functions that operate on the struct to Ruby via FFI. This allows metrics calculated by the C code to be accessed from Ruby while retaining performance compared to a pure Ruby implementation.
Wii Ruby All Work And No Play Just Wont DoLittleBIGRuby
This document discusses using a Wii remote with Ruby code to create interactive programs. It provides an overview of the necessary hardware, libraries for connecting to the Wii remote from Ruby like WiiUseJRuby, and the Monkeybars GUI library. It also demonstrates example code for mapping button presses and motion data to methods, and includes demos of using the Wii remote for MIDI music and motion plotting. The document encourages an exploratory approach to programming with the Wii remote.
Practical Puppet Systems Building Systems 1LittleBIGRuby
The document discusses various topics related to systems building including testing code frequently, tribes throughout history, clouds and evolution. It mentions cracking the crystal of truth and using code to build infrastructure. The document provides encouragement to use powers for awesome and asks if there are any questions. Contact information is provided at the end.
This document provides an overview and introduction to code reading skills and the RestClient library. It discusses why code reading is an important skill, introduces RestClient as a library for making HTTP requests, and provides examples of using RestClient to interact with Twitter's API. It also summarizes some other Ruby libraries and concepts discussed in the document like CSV, threading, and signal handling.
Integra Evolution It Cunsulting Servicesguestbed31a
The document outlines various consulting services provided by Integra Evolution's IT Division, including project management, business process engineering, IT infrastructure design and optimization, IT database services, IT office applications, IT development for special applications, and quality assurance according to ISO standards. Key services involve implementing methodologies for project management, developing business intelligence systems, configuring servers and networks, implementing complex systems like ERP, and providing training on Microsoft Office applications.
Beijing Perl Workshop 2008 Hiveminder Secret SauceJesse Vincent
Template::Declare is a pure Perl templating engine that allows templates to be treated like code. Templates can be refactored, use object orientation and mixins. Tags are implemented as closures that can output content immediately or return closures. CSS::Squish is a CSS compiler that combines multiple small CSS files into one large file for easier serving, improving performance by allowing browsers to cache the combined file.
The document discusses high performance websites, introducing xDebug profiling, Kcachegrind, and JMeter. It provides instructions for installing necessary software on a virtual machine, including Apache, xDebug, JMeter, and Kcachegrind. The document then demonstrates how to use these tools to optimize website performance, including profiling a sample extension in TYPO3, identifying optimization opportunities, and implementing caching. Finally, it shows how to test website performance using JMeter, including building test plans, recording tests, distributed testing on Amazon EC2, and analyzing results.
The document provides an introduction to C++ programming including definitions of key concepts like compilers, variables, data types, operators, and common errors. It discusses rules for naming variables in C++ and different types of errors like syntax errors, semantic errors, type errors, runtime errors, and logical errors. Code snippets demonstrating these concepts are provided along with examples of errors. Best practices for programming and naming conventions are also outlined.
Wii Ruby All Work And No Play Just Wont DoLittleBIGRuby
This document discusses using a Wii remote with Ruby code to create interactive programs. It provides an overview of the necessary hardware, libraries for connecting to the Wii remote from Ruby like WiiUseJRuby, and the Monkeybars GUI library. It also demonstrates example code for mapping button presses and motion data to methods, and includes demos of using the Wii remote for MIDI music and motion plotting. The document encourages an exploratory approach to programming with the Wii remote.
Practical Puppet Systems Building Systems 1LittleBIGRuby
The document discusses various topics related to systems building including testing code frequently, tribes throughout history, clouds and evolution. It mentions cracking the crystal of truth and using code to build infrastructure. The document provides encouragement to use powers for awesome and asks if there are any questions. Contact information is provided at the end.
This document provides an overview and introduction to code reading skills and the RestClient library. It discusses why code reading is an important skill, introduces RestClient as a library for making HTTP requests, and provides examples of using RestClient to interact with Twitter's API. It also summarizes some other Ruby libraries and concepts discussed in the document like CSV, threading, and signal handling.
Integra Evolution It Cunsulting Servicesguestbed31a
The document outlines various consulting services provided by Integra Evolution's IT Division, including project management, business process engineering, IT infrastructure design and optimization, IT database services, IT office applications, IT development for special applications, and quality assurance according to ISO standards. Key services involve implementing methodologies for project management, developing business intelligence systems, configuring servers and networks, implementing complex systems like ERP, and providing training on Microsoft Office applications.
Beijing Perl Workshop 2008 Hiveminder Secret SauceJesse Vincent
Template::Declare is a pure Perl templating engine that allows templates to be treated like code. Templates can be refactored, use object orientation and mixins. Tags are implemented as closures that can output content immediately or return closures. CSS::Squish is a CSS compiler that combines multiple small CSS files into one large file for easier serving, improving performance by allowing browsers to cache the combined file.
The document discusses high performance websites, introducing xDebug profiling, Kcachegrind, and JMeter. It provides instructions for installing necessary software on a virtual machine, including Apache, xDebug, JMeter, and Kcachegrind. The document then demonstrates how to use these tools to optimize website performance, including profiling a sample extension in TYPO3, identifying optimization opportunities, and implementing caching. Finally, it shows how to test website performance using JMeter, including building test plans, recording tests, distributed testing on Amazon EC2, and analyzing results.
The document provides an introduction to C++ programming including definitions of key concepts like compilers, variables, data types, operators, and common errors. It discusses rules for naming variables in C++ and different types of errors like syntax errors, semantic errors, type errors, runtime errors, and logical errors. Code snippets demonstrating these concepts are provided along with examples of errors. Best practices for programming and naming conventions are also outlined.
This time it was the microcosm that brought us a few interesting bugs. We have checked the open-source project μManager with our analyzer PVS-Studio. This project is a software package for automated microscope image acquisition.
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...Andrey Karpov
The article demonstrates errors detected with the static code analyzer integrated into Visual Studio 2010. The research was performed on five open source projects. The same projects were also checked with PVS-Studio. Results of comparing these two tools are presented at the end of the article.
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...PVS-Studio
The article demonstrates errors detected with the static code analyzer integrated into Visual Studio 2010. The research was performed on five open source projects. The same projects were also checked with PVS-Studio. Results of comparing these two tools are presented at the end of the article.
I need help to modify my code according to the instructions- Modify th.pdfpnaran46
I need help to modify my code according to the instructions:
Modify the program you created in Lab Assignment #9 (Babbage's Cabbage's, Part 3) to include
the following features:
Use parallel arrays to store the full name and gross pay of all employees entered. The size of the
arrays must be easy to change using a single symbolic constant. At the end of the program, after
all the individual employee records have been input and processed, write a summary table to the
report file listing the employees entered and their gross pay amounts. See the sample report that
follows for an example. (Your program may only store these two specific pieces of employee
data in arrays. You will not earn credit for this feature if you create additional arrays for other
pieces of employee data.)
Create individual functions for computing the sum of the gross pay amounts, the average, finding
the maximum gross pay, and the minimum gross pay. Each of these four functions can accept
only the array of gross pay amounts and number of valid data items as parameters, and cannot
depend on the array being arranged in order. Display the total, average, minimum, and maximum
of the gross pay amounts in the report file summary.
Use the optimized version of the Bubble Sort (v.3) so that the summary table of employee names
and gross pay amounts is arranged in descending order by gross pay.
Read input from a data file, rather than the user. See the sample data file that follows for an
example (note that the amount of the transportation deduction is supplied directly). You may
assume that all data provided in the file is valid. Remove all code related to keyboard input and
data validation so that the program simply reads from the data file and writes to the report file
without needing any input from the user.
Sample Report File
Submissions whose programs do not compile without errors, do not use a modular style (i.e., all
of the program code appears in the main module), or contain any of the items listed below, will
receive a grade of zero:
Global variables, Recursive module calls, vectors, structs, or classes, The line using namespace
std; Inclusion of libraries that have not been introduced as part of the class (including those that
are specific to a particular operating system), or use of their commands, Calls to the system
function
This is my code that needs to be modified:
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <ostream>
#define min_hours 10.0
#define max_hours 55.0
#define min_hourly_rate 15.00
#define max_hourly_rate 65.00
#define overtime_limit 34.0
void input_employee_data(double &hours_worked, double &hourly_wage);
void calculate_gross_pay(double &hours_worked, double &hourly_wage, double& ovt_hours,
double& reg_hours, double &gross_pay);
void calculate_net_pay(double &gross_pay, double& deduct, double &net_pay, double &taxes);
std::string input_full_name(std::string& first_name,
std::string& last_name);
std::string join_names.
ManageIQ currently runs on Ruby on Rails 3. Aaron "tenderlove" Patterson presents his effort to migrate to RoR 4, which entails some changes in the code to take advantage of the latest advances in RoR.
For more on ManageIQ, see http://manageiq.org/
The document discusses compiler code generation optimizations in Objective-C and provides examples comparing different method implementations. It shows the assembly code generated by the compiler for methods that access properties and ivars directly versus through accessor methods. Direct access generally results in faster code due to making fewer calls and having less overhead from message passing. The document recommends coding with compiler optimizations in mind to generate faster code.
The document provides details of programs to be implemented in C++ and Java as part of an Object Oriented Programming lab. The C++ programs include implementations of inline function overloading, complex numbers using operator overloading, friend functions, string concatenation using dynamic memory allocation, type conversion using complex numbers, managing bank accounts using inheritance, and a stack class with exception handling. The Java programs include writing simple programs, palindrome checking using strings, interfaces, inheritance, exception handling, and multithreaded programs.
This document provides an overview of type conversion in C++. It discusses implicit and explicit type conversion, including promotion and demotion. It covers numeric type conversion between integral types like int, float, double, and char. It also discusses enum types in C++ and how to declare and use enumerated variable types. Finally, it briefly introduces relational operators. The key topics covered are type conversion between numeric types, both implicitly through promotion and explicitly through casting, as well as how to define and use enum types for a set of named constants.
Consequences of using the Copy-Paste method in C++ programming and how to dea...Andrey Karpov
I create the PVS-Studio analyzer detecting errors in source code of C/C++/C++0x software. So I have to review a large amount of source code of various applications where we detected suspicious code fragments with the help of PVS-Studio. I have collected a lot of examples demonstrating that an error occurred because of copying and modifying a code fragment. Of course, it has been known for a long time that using Copy-Paste in programming is a bad thing. But let's try to investigate this problem closely instead of limiting ourselves to just saying "do not copy the code".
This document discusses parallel computing with MATLAB. It introduces MATLAB and parallel computing concepts. It then covers how MATLAB can be used for parallel computing on multi-core systems and distributed computing servers. It discusses parallel commands in MATLAB like matlabpool, parfor, pmode, and spmd. It also demonstrates how to test the efficiency of parallel code and provides an example comparing the execution times of serial and parallel prime number calculation codes.
The document discusses inline functions in C++. Inline functions allow code from a function to be pasted directly into the call site rather than executing a function call. This avoids overhead from calling and returning from functions. Good candidates for inline are small, simple functions called frequently. The document provides an example of a function defined with the inline keyword and the optimizations a compiler may perform after inlining. It also compares inline functions to macros and discusses where inline functions are best used.
The document discusses an introduction to Ruby on Rails. It provides an overview of Ruby and Rails, demonstrates how to build a sample application using Rails with employers and jobs, and discusses concepts like MVC architecture, scaffolding, associations, and RESTful routing. The sample application allows users to view, create, edit and delete employer and job records along with their associations.
The document provides an introduction to Ruby on Rails including:
- An overview of Ruby and its history and features
- An overview of Rails, the MVC framework, and its history and components
- A tutorial on building a sample application in Rails with Employers and Jobs models using scaffolds and migrations.
How I Built a Power Debugger Out of the Standard Library and Things I Found o...doughellmann
The document describes a Python debugger called Smiley that was built using the standard library and things found online. Smiley can record calls and data during program execution, enable remote monitoring and local analysis of runs, and browse run histories. It works by tracing program execution using a tracer class and publishing trace events to a publisher. Traces are stored in a SQLite database for later retrieval and replay.
This document discusses operator overloading in C++. It begins by defining operator overloading as giving special meanings to operators for user-defined data types. It then covers overloading unary and binary operators using member functions and friend functions. Some key points include: only existing operators can be overloaded, binary operators take operands as arguments, and type conversions between basic and user-defined types require custom conversion routines like constructors or casting functions. The document also provides examples of overloading operators for complex numbers and strings.
I am Bernard. I am a C Programming Assignment Help Expert at programminghomeworkhelp.com. I hold a Ph.D. in Computer Science from, University of Leeds, UK. I have been helping students with their homework for the past 12 years. I solve assignments related to C Programming.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.You can also call on +1 678 648 4277 for any assistance with C Programming assignments.
Programs are complete in best of my knowledge with zero compilation error in IDE Bloodshed Dev-C++. These can be easily portable to any versions of Visual Studio or Qt. If you need any guidance please let me know via comments and Always Enjoy Programming.
Hiveminder - Everything but the Secret SauceJesse Vincent
Ten tools and techniques to help you:
Find bugs faster バグの検出をもっと素早く
Build web apps ウェブアプリの構築
Ship software ソフトのリリース
Get input from users ユーザからの入力を受けつける
Own the Inbox 受信箱を用意する
今日の話
The document discusses the building blocks of modularity, including different types of connascence (ways that software elements are connected) such as connascence of name, position, meaning, algorithm, and execution. It advocates applying principles like the rule of locality, degree, and DRY (don't repeat yourself) to reduce strong connascence and increase loose coupling between modules. This improves modularity, reusability, and maintainability of software designs.
The document discusses Rack, a modular web server interface for Ruby that allows web applications and frameworks to be written as middleware stacks. It covers topics like Rack applications as middleware, common Rack middleware components, building applications with Rack and middleware, and integrating Rack middleware with frameworks like Rails.
This time it was the microcosm that brought us a few interesting bugs. We have checked the open-source project μManager with our analyzer PVS-Studio. This project is a software package for automated microscope image acquisition.
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...Andrey Karpov
The article demonstrates errors detected with the static code analyzer integrated into Visual Studio 2010. The research was performed on five open source projects. The same projects were also checked with PVS-Studio. Results of comparing these two tools are presented at the end of the article.
Comparing the general static analysis in Visual Studio 2010 and PVS-Studio by...PVS-Studio
The article demonstrates errors detected with the static code analyzer integrated into Visual Studio 2010. The research was performed on five open source projects. The same projects were also checked with PVS-Studio. Results of comparing these two tools are presented at the end of the article.
I need help to modify my code according to the instructions- Modify th.pdfpnaran46
I need help to modify my code according to the instructions:
Modify the program you created in Lab Assignment #9 (Babbage's Cabbage's, Part 3) to include
the following features:
Use parallel arrays to store the full name and gross pay of all employees entered. The size of the
arrays must be easy to change using a single symbolic constant. At the end of the program, after
all the individual employee records have been input and processed, write a summary table to the
report file listing the employees entered and their gross pay amounts. See the sample report that
follows for an example. (Your program may only store these two specific pieces of employee
data in arrays. You will not earn credit for this feature if you create additional arrays for other
pieces of employee data.)
Create individual functions for computing the sum of the gross pay amounts, the average, finding
the maximum gross pay, and the minimum gross pay. Each of these four functions can accept
only the array of gross pay amounts and number of valid data items as parameters, and cannot
depend on the array being arranged in order. Display the total, average, minimum, and maximum
of the gross pay amounts in the report file summary.
Use the optimized version of the Bubble Sort (v.3) so that the summary table of employee names
and gross pay amounts is arranged in descending order by gross pay.
Read input from a data file, rather than the user. See the sample data file that follows for an
example (note that the amount of the transportation deduction is supplied directly). You may
assume that all data provided in the file is valid. Remove all code related to keyboard input and
data validation so that the program simply reads from the data file and writes to the report file
without needing any input from the user.
Sample Report File
Submissions whose programs do not compile without errors, do not use a modular style (i.e., all
of the program code appears in the main module), or contain any of the items listed below, will
receive a grade of zero:
Global variables, Recursive module calls, vectors, structs, or classes, The line using namespace
std; Inclusion of libraries that have not been introduced as part of the class (including those that
are specific to a particular operating system), or use of their commands, Calls to the system
function
This is my code that needs to be modified:
#include <iostream>
#include <iomanip>
#include <string>
#include <fstream>
#include <ostream>
#define min_hours 10.0
#define max_hours 55.0
#define min_hourly_rate 15.00
#define max_hourly_rate 65.00
#define overtime_limit 34.0
void input_employee_data(double &hours_worked, double &hourly_wage);
void calculate_gross_pay(double &hours_worked, double &hourly_wage, double& ovt_hours,
double& reg_hours, double &gross_pay);
void calculate_net_pay(double &gross_pay, double& deduct, double &net_pay, double &taxes);
std::string input_full_name(std::string& first_name,
std::string& last_name);
std::string join_names.
ManageIQ currently runs on Ruby on Rails 3. Aaron "tenderlove" Patterson presents his effort to migrate to RoR 4, which entails some changes in the code to take advantage of the latest advances in RoR.
For more on ManageIQ, see http://manageiq.org/
The document discusses compiler code generation optimizations in Objective-C and provides examples comparing different method implementations. It shows the assembly code generated by the compiler for methods that access properties and ivars directly versus through accessor methods. Direct access generally results in faster code due to making fewer calls and having less overhead from message passing. The document recommends coding with compiler optimizations in mind to generate faster code.
The document provides details of programs to be implemented in C++ and Java as part of an Object Oriented Programming lab. The C++ programs include implementations of inline function overloading, complex numbers using operator overloading, friend functions, string concatenation using dynamic memory allocation, type conversion using complex numbers, managing bank accounts using inheritance, and a stack class with exception handling. The Java programs include writing simple programs, palindrome checking using strings, interfaces, inheritance, exception handling, and multithreaded programs.
This document provides an overview of type conversion in C++. It discusses implicit and explicit type conversion, including promotion and demotion. It covers numeric type conversion between integral types like int, float, double, and char. It also discusses enum types in C++ and how to declare and use enumerated variable types. Finally, it briefly introduces relational operators. The key topics covered are type conversion between numeric types, both implicitly through promotion and explicitly through casting, as well as how to define and use enum types for a set of named constants.
Consequences of using the Copy-Paste method in C++ programming and how to dea...Andrey Karpov
I create the PVS-Studio analyzer detecting errors in source code of C/C++/C++0x software. So I have to review a large amount of source code of various applications where we detected suspicious code fragments with the help of PVS-Studio. I have collected a lot of examples demonstrating that an error occurred because of copying and modifying a code fragment. Of course, it has been known for a long time that using Copy-Paste in programming is a bad thing. But let's try to investigate this problem closely instead of limiting ourselves to just saying "do not copy the code".
This document discusses parallel computing with MATLAB. It introduces MATLAB and parallel computing concepts. It then covers how MATLAB can be used for parallel computing on multi-core systems and distributed computing servers. It discusses parallel commands in MATLAB like matlabpool, parfor, pmode, and spmd. It also demonstrates how to test the efficiency of parallel code and provides an example comparing the execution times of serial and parallel prime number calculation codes.
The document discusses inline functions in C++. Inline functions allow code from a function to be pasted directly into the call site rather than executing a function call. This avoids overhead from calling and returning from functions. Good candidates for inline are small, simple functions called frequently. The document provides an example of a function defined with the inline keyword and the optimizations a compiler may perform after inlining. It also compares inline functions to macros and discusses where inline functions are best used.
The document discusses an introduction to Ruby on Rails. It provides an overview of Ruby and Rails, demonstrates how to build a sample application using Rails with employers and jobs, and discusses concepts like MVC architecture, scaffolding, associations, and RESTful routing. The sample application allows users to view, create, edit and delete employer and job records along with their associations.
The document provides an introduction to Ruby on Rails including:
- An overview of Ruby and its history and features
- An overview of Rails, the MVC framework, and its history and components
- A tutorial on building a sample application in Rails with Employers and Jobs models using scaffolds and migrations.
How I Built a Power Debugger Out of the Standard Library and Things I Found o...doughellmann
The document describes a Python debugger called Smiley that was built using the standard library and things found online. Smiley can record calls and data during program execution, enable remote monitoring and local analysis of runs, and browse run histories. It works by tracing program execution using a tracer class and publishing trace events to a publisher. Traces are stored in a SQLite database for later retrieval and replay.
This document discusses operator overloading in C++. It begins by defining operator overloading as giving special meanings to operators for user-defined data types. It then covers overloading unary and binary operators using member functions and friend functions. Some key points include: only existing operators can be overloaded, binary operators take operands as arguments, and type conversions between basic and user-defined types require custom conversion routines like constructors or casting functions. The document also provides examples of overloading operators for complex numbers and strings.
I am Bernard. I am a C Programming Assignment Help Expert at programminghomeworkhelp.com. I hold a Ph.D. in Computer Science from, University of Leeds, UK. I have been helping students with their homework for the past 12 years. I solve assignments related to C Programming.
Visit programminghomeworkhelp.com or email support@programminghomeworkhelp.com.You can also call on +1 678 648 4277 for any assistance with C Programming assignments.
Programs are complete in best of my knowledge with zero compilation error in IDE Bloodshed Dev-C++. These can be easily portable to any versions of Visual Studio or Qt. If you need any guidance please let me know via comments and Always Enjoy Programming.
Hiveminder - Everything but the Secret SauceJesse Vincent
Ten tools and techniques to help you:
Find bugs faster バグの検出をもっと素早く
Build web apps ウェブアプリの構築
Ship software ソフトのリリース
Get input from users ユーザからの入力を受けつける
Own the Inbox 受信箱を用意する
今日の話
The document discusses the building blocks of modularity, including different types of connascence (ways that software elements are connected) such as connascence of name, position, meaning, algorithm, and execution. It advocates applying principles like the rule of locality, degree, and DRY (don't repeat yourself) to reduce strong connascence and increase loose coupling between modules. This improves modularity, reusability, and maintainability of software designs.
The document discusses Rack, a modular web server interface for Ruby that allows web applications and frameworks to be written as middleware stacks. It covers topics like Rack applications as middleware, common Rack middleware components, building applications with Rack and middleware, and integrating Rack middleware with frameworks like Rails.
The document discusses outside-in development and behavior-driven development techniques. It provides examples of writing feature files with scenarios and steps, and creating corresponding step definitions to define the behavior. It also discusses structuring the test code, using fixtures/factories, and integrating with testing frameworks. The overall process involves writing scenarios, defining pending steps, implementing step definitions, refactoring code, and repeating.
The document discusses various topics related to systems building including testing code frequently, tribes throughout history, clouds and evolution. It mentions cracking the crystal of truth and using code to build infrastructure. The document encourages using one's powers for awesome and ends by providing contact information for questions.
This document discusses concepts related to living a fulfilling life through creativity and flow. It is divided into four sections: Discovery, discussing seeing with new eyes; Resistance, about overcoming obstacles to creative pursuits; Flow, explaining how flow states provide the most happiness; and Engagement, emphasizing managing one's energy across different domains. The overall message encourages finding fulfillment through creative challenges that match one's skills.
Compiling And Optimizing Scripting LanguagesLittleBIGRuby
This document discusses the phc compiler for PHP. It begins with an introduction and motivation for compiling PHP. It then outlines the current state of phc, including challenges to compilation and phc's solution of using the PHP C API. The document discusses next steps for phc, including simple and advanced optimizations. It concludes by discussing experiences with using phc to compile PHP code.
This document provides an overview of Sequel, a Ruby ORM and database toolkit. It discusses Sequel's history and key features, including database support, datasets, models, associations, and eager loading. Sequel aims to provide a clean Ruby API for building queries and interacting with databases while avoiding complexity where possible. It emphasizes features like connection pooling, functional-style datasets, and explicit association methods over proxies.
9. LIBFFI
http://sourceware.org/libffi/
“A foreign function interface is the
popular name for the interface that
allows code written in one language
to call code written in another
language.”
10. e
m
i
Application
t
n
uses
u
libsomething_foo()
R FFI
libsomething.so
12. 1 #ifndef __SIMPLE_METRICS_H__
2 #define __SIMPLE_METRICS_H__
3 #include <stdlib.h>
4 #include <math.h>
5
6 typedef struct _simple_metrics{
7 double min;
8 double max;
9 double sum;
10 double sumsq;
11 long count;
12 } simple_metrics ;
13
14 simple_metrics* simple_metrics_new();
15 void simple_metrics_free( simple_metrics* sm );
16 void simple_metrics_update( simple_metrics* sm, double value );
17 double simple_metrics_mean( simple_metrics* sm );
18 double simple_metrics_min( simple_metrics* sm );
19 double simple_metrics_max( simple_metrics* sm );
20 double simple_metrics_sum( simple_metrics* sm );
21 long simple_metrics_count( simple_metrics* sm );
22 double simple_metrics_stddev( simple_metrics* sm );
23 double simple_metrics_rate( simple_metrics* sm );
24
25 #endif
13. 1 class Metric
2 attr_reader :name
3 def initialize( name )
4 @name
5 end
6
7 def update( new_value) ... end
8 def count ... end
9 def max ... end
10 def mean ... end
11 def min ... end
12 def rate ... end
13 def sum ... end
14 def stddev ... end
15 end
16. 35 module SimpleMetrics
36 module FFI
37 class Metric < ::SimpleMetrics::Common
38 include ::SimpleMetrics::FFI
39 def initialize( name )
40 super
41 @impl = FFI.simple_metrics_new
42 end
43
44 def update( v )
45 simple_metrics_update( @impl, v )
46 end
47
48 self.keys.each do |f|
49 module_eval <<-code
50 def #{f}
51 simple_metrics_#{f}( @impl )
52 end
53 code
54 end
55 end
56 end
57 end
19. MEANINGLESS METRICS
Traditional C
FFI
Extension
Jeremy’s Time 40 minutes 70 minutes
1 Million update()
1.16 sec 0.42 sec
calls
Will it Blend run
Yes No
on JRuby?
20. % ruby ~/Projects/simple_metrics/example/bench.rb 1000000
generating 1000000 random numbers between 0 and 10,000
Rehearsal -----------------------------------------------
ext 0.420000 0.000000 0.420000 ( 0.460806)
ffi 1.160000 0.000000 1.160000 ( 1.171498)
-------------------------------------- total: 1.580000sec
user system total real
ext 0.420000 0.010000 0.430000 ( 0.424809)
ffi 1.160000 0.000000 1.160000 ( 1.182928)
% ./bin/jruby ~/Projects/simple_metrics/example/bench.rb 1000000
generating 1000000 random numbers between 0 and 10,000
Skipping Ext
Rehearsal -----------------------------------------------
ffi 0.922000 0.000000 0.922000 ( 0.922000)
-------------------------------------- total: 0.922000sec
user system total real
ffi 0.834000 0.000000 0.834000 ( 0.834000)
24. THANKS
• Wayne Meissner - adding libffi to JRuby and providing the
ffi gem for MRI.
• Evan Phoenix - using libffi in Rubinius
• Authors of the examples on the Project Kenai wiki