Profiling and benchmarking tools like perftools.rb, Benchmark, and ruby-prof can help optimize Ruby code by identifying slow parts. These tools sample programs to measure CPU time, memory usage, and other metrics. Benchmark allows basic timing comparisons, while profilers like perftools.rb and ruby-prof provide call graphs and other visualizations to pinpoint where to optimize. These techniques help focus optimization efforts on the most impactful areas.
Node.js behind: V8 and its optimizationsDawid Rusnak
Do you know how really your code is working behind? It’s very useful to be aware of mechanisms and optimizations which your engine will perform. I will tell you how your code is processed and run, and how it could affect you in day-by-day development.
Performed at Code Europe 2017: https://www.codeeurope.pl
JVM Mechanics: Understanding the JIT's TricksDoug Hawkins
In this talk, we'll walkthrough how the JIT optimizes a piece Java code step-by-step. In doing so, you'll learn some of the amazing feats of optimization that JVMs can perform, but also some surprisingly simple things that prevent your code from running fast.
In this talk about performance for the 2018-01-25 Dallas Oracle Users Group meeting, Cary Millsap talks about application design, ways to control Oracle sql_trace, measurement intrusion, and function interposition.
This talk is a look into some of the surprising performance cases in Java -- with the goal of illustrating a few simple truths about the nature of compilers.
An overview of the inner-workings of OpenJDK - with emphasis on...
- what triggers the just-in-time compiler (JIT)
- types of speculative optimizations performed by the JIT
- aspects of the Java language & ecosystem that make ahead-of-time (AOT) compilation challenging
Simple, fast, and scalable torch7 tutorialJin-Hwa Kim
A tutorial based on basic information of Torch7. It covers installation, simple runable codes, tensor manipulations, sweep out key-packages and post-hoc audience q&a.
In this presentation speaker considered theoretical basics of using the redux-saga library, which was created for facilitating the organization of the so-called “side effects” (for example, asynchronous operations). The event participants obtained practical tips on using saga in real-life projects.
This presentation by Igor Nesterenko (Lead Software Engineer, Consultant, GlobalLogic, Kharkiv) was delivered at GlobalLogic Kharkiv JS TechTalk #2 on August 17, 2018.
Node.js behind: V8 and its optimizationsDawid Rusnak
Do you know how really your code is working behind? It’s very useful to be aware of mechanisms and optimizations which your engine will perform. I will tell you how your code is processed and run, and how it could affect you in day-by-day development.
Performed at Code Europe 2017: https://www.codeeurope.pl
JVM Mechanics: Understanding the JIT's TricksDoug Hawkins
In this talk, we'll walkthrough how the JIT optimizes a piece Java code step-by-step. In doing so, you'll learn some of the amazing feats of optimization that JVMs can perform, but also some surprisingly simple things that prevent your code from running fast.
In this talk about performance for the 2018-01-25 Dallas Oracle Users Group meeting, Cary Millsap talks about application design, ways to control Oracle sql_trace, measurement intrusion, and function interposition.
This talk is a look into some of the surprising performance cases in Java -- with the goal of illustrating a few simple truths about the nature of compilers.
An overview of the inner-workings of OpenJDK - with emphasis on...
- what triggers the just-in-time compiler (JIT)
- types of speculative optimizations performed by the JIT
- aspects of the Java language & ecosystem that make ahead-of-time (AOT) compilation challenging
Simple, fast, and scalable torch7 tutorialJin-Hwa Kim
A tutorial based on basic information of Torch7. It covers installation, simple runable codes, tensor manipulations, sweep out key-packages and post-hoc audience q&a.
In this presentation speaker considered theoretical basics of using the redux-saga library, which was created for facilitating the organization of the so-called “side effects” (for example, asynchronous operations). The event participants obtained practical tips on using saga in real-life projects.
This presentation by Igor Nesterenko (Lead Software Engineer, Consultant, GlobalLogic, Kharkiv) was delivered at GlobalLogic Kharkiv JS TechTalk #2 on August 17, 2018.
It seemed that long forum debates about methods of measuring algorithm's running time, functions to use and precision that should be expected were over. Unfortunately, we have to return to this question once again. Today we will discuss the question how we should measure speed of a parallel algorithm.
Use C++ to Manipulate mozSettings in GeckoChih-Hsuan Kuo
If you want to manipulate mozSettings with JavaScript, you can reference to Settings API on MDN (https://developer.mozilla.org/en-US/docs/Web/API/Settings_API).
But if you want to manipulate it with C++, we can only reference to the codebase of Gecko. Now, let me show you some example.
From Europython 2016
Mocking is a valuable technique for writing tests but mocking effectively is often a stumbling block for many developers and can raise questions about its overall value as a technique.
The audience will have some familiarity with unit testing and may have tried mocking before, but some introduction will be provided for those who haven’t. We will look at some features and techniques of Python’s unittest.mock library and cover some useful tips and common scenarios, so this will be useful to those who have some experience mocking but would like to do so more effectively.
Video: https://www.youtube.com/watch?v=Ahnw72diels
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...dantleech
Did you know that Generators and Pipelines can be combined in order to
solve software engineering problems?
Generators have been available to us in PHP for about 5 years, they are a very
powerful tool in a developers toolbox, they can be used to make your life
easier (e.g. as data providers in PHPUnit), to help process large amounts of
data, and even to enable co-operative multi-tasking.
Pipelines provide a way to compose complex tasks from stages.
In this talk we will briefly discuss a specific problem in PHPBench (a
benchmarking tool for PHP) which can be solved through the use of Generators
(and pipelines!). We will then explore both topics generally, before combining
them into an Incredible Machine in a live coding session.
Python is one of the most popular programming languages today. It’s an interpreted and high-level language with elegant and readable syntax. However, Python is generally significantly slower than Java, C#, and especially C, C++, or Fortran. Sometimes performance issues and bottlenecks might seriously affect the usability of applications.
Fortunately, in most cases, there are solutions to improve the performance of Python programs. There are choices developers can take to improve the speed of their code. For example, the general advice is to use optimized Python built-in or third-party routines, usually written in C or Cython. Besides, it’s faster to work with local variables than with globals, so it’s a good practice to copy a global variable to a local before the loop. And so on.
QA Fest 2019. Saar Rachamim. Developing Tools, While TestingQAFest
Our daily work is comprised of testing a product and improve its quality. However, here and there, we can come to a state where we find a need to build a tool, that can make our work easierbetter.
I will share from my experience when I found myself in a situation where building a tool was needed.
We will start with a web application that allows you to know when a food delivery you ordered arrives to the office, and then we will focus on a tool that test the performance of an app from the UI side. We will do a live demo for both of them.
Did you know that there is a function in the Objective-C runtime that gives you exactly this list of classes in your app?
With this tool, you can easily build a debug view which will enable you to instantiate any of your ViewControllers, and save you a lot of development time.
Programmation fonctionnelle en JavaScriptLoïc Knuchel
La programmation fonctionnelle permet de faire du code plus modulaire, avec moins de bugs et de manière plus productive !!!
Cette présentation montre comment la programmation fonctionnelle peut tenir se promesse et comment l'appliquer avec JavaScript.
It seemed that long forum debates about methods of measuring algorithm's running time, functions to use and precision that should be expected were over. Unfortunately, we have to return to this question once again. Today we will discuss the question how we should measure speed of a parallel algorithm.
Use C++ to Manipulate mozSettings in GeckoChih-Hsuan Kuo
If you want to manipulate mozSettings with JavaScript, you can reference to Settings API on MDN (https://developer.mozilla.org/en-US/docs/Web/API/Settings_API).
But if you want to manipulate it with C++, we can only reference to the codebase of Gecko. Now, let me show you some example.
From Europython 2016
Mocking is a valuable technique for writing tests but mocking effectively is often a stumbling block for many developers and can raise questions about its overall value as a technique.
The audience will have some familiarity with unit testing and may have tried mocking before, but some introduction will be provided for those who haven’t. We will look at some features and techniques of Python’s unittest.mock library and cover some useful tips and common scenarios, so this will be useful to those who have some experience mocking but would like to do so more effectively.
Video: https://www.youtube.com/watch?v=Ahnw72diels
Building and Incredible Machine with Pipelines and Generators in PHP (IPC Ber...dantleech
Did you know that Generators and Pipelines can be combined in order to
solve software engineering problems?
Generators have been available to us in PHP for about 5 years, they are a very
powerful tool in a developers toolbox, they can be used to make your life
easier (e.g. as data providers in PHPUnit), to help process large amounts of
data, and even to enable co-operative multi-tasking.
Pipelines provide a way to compose complex tasks from stages.
In this talk we will briefly discuss a specific problem in PHPBench (a
benchmarking tool for PHP) which can be solved through the use of Generators
(and pipelines!). We will then explore both topics generally, before combining
them into an Incredible Machine in a live coding session.
Python is one of the most popular programming languages today. It’s an interpreted and high-level language with elegant and readable syntax. However, Python is generally significantly slower than Java, C#, and especially C, C++, or Fortran. Sometimes performance issues and bottlenecks might seriously affect the usability of applications.
Fortunately, in most cases, there are solutions to improve the performance of Python programs. There are choices developers can take to improve the speed of their code. For example, the general advice is to use optimized Python built-in or third-party routines, usually written in C or Cython. Besides, it’s faster to work with local variables than with globals, so it’s a good practice to copy a global variable to a local before the loop. And so on.
QA Fest 2019. Saar Rachamim. Developing Tools, While TestingQAFest
Our daily work is comprised of testing a product and improve its quality. However, here and there, we can come to a state where we find a need to build a tool, that can make our work easierbetter.
I will share from my experience when I found myself in a situation where building a tool was needed.
We will start with a web application that allows you to know when a food delivery you ordered arrives to the office, and then we will focus on a tool that test the performance of an app from the UI side. We will do a live demo for both of them.
Did you know that there is a function in the Objective-C runtime that gives you exactly this list of classes in your app?
With this tool, you can easily build a debug view which will enable you to instantiate any of your ViewControllers, and save you a lot of development time.
Programmation fonctionnelle en JavaScriptLoïc Knuchel
La programmation fonctionnelle permet de faire du code plus modulaire, avec moins de bugs et de manière plus productive !!!
Cette présentation montre comment la programmation fonctionnelle peut tenir se promesse et comment l'appliquer avec JavaScript.
Breakfast has a rich history and heritage in the UK and has long been hailed as the most important meal of the day. Here are some facts to help whet your appetite.
Hijama (Arabic: حجامة lit. "sucking") is the Arabic term for wet cupping, where blood is drawn by vacuum from a small skin incision for therapeutic purposes.The practice has Greek and Persian origin and is mentioned by Hippocrates.
Where the wild things are - Benchmarking and Micro-OptimisationsMatt Warren
You don’t want to prematurely optimise, but sometimes you want to optimise, the question is - where to start? Profiling and Benchmarking can help you figure out what your application is doing and where performance problems could arise - allowing you to find (and fix!) them before your customers do.
If you aren’t already benchmarking your code this talk will offer some starting points. We’ll look at how to accurately benchmark in .NET and things to avoid. Along the way we’ll also discover some surprising code optimisations!
Performance and how to measure it - ProgSCon London 2016Matt Warren
Starting with the premise that "Performance is a Feature", this session will look at how to measure, what to measure and how get the best performance from your .NET code.
We will look at real-world examples from the Roslyn code-base and StackOverflow (the product), including how the .NET Garbage Collector needs to be tamed!
Benchy: Lightweight framework for Performance Benchmarks Marcel Caraciolo
Benchy: Lightweight framework for Performance Benchmarks on Python Scripts.
Presented at XXVI Pernambuco Python User Group Meeting at Recife, Pernambuco, Brazil on 06.04.2013
(PFC302) Performance Benchmarking on AWS | AWS re:Invent 2014Amazon Web Services
In this session, we explain how to measure the key performance-impacting metrics in a cloud-based application and best practices for a reliable benchmarking process. Measuring the performance of applications correctly can be challenging and there are many tools available to measure and track performance. This session will provide you with specific examples of good and bad tests. We make it clear how to get reliable measurements of and how to map benchmark results to your application. We also cover the importance of selecting tests wisely, repeating tests, and measuring variability. In addition a customer will provide real-life examples of how they developed their application testing stack, utilize it for repeatable testing and identify bottlenecks.
Instrumenting application code is like flossing your teeth. Developers know they ought to be doing it more often. Code instrumentation is an important practice for establishing baseline performance metrics and identifying bottlenecks. Getting the right metrics is core to understanding how much concurrency your application can handle, determining what latency is normal for the application, and indicating when performance is deviating from those norms.
While most developers acknowledge the value of instrumentation, few actually implement it. If Bytecode injection sounds as scary as a root canal, take heart, effective instrumentation doesn't have to be complicated. I've written an open-source instrumentation framework to encourage developers to get the metrics they need to pilot their application safely. We'll examine some strategies for code instrumentation, run some load tests, and make sense of the numbers.
Talk for PerconaLive 2016 by Brendan Gregg. Video: https://www.youtube.com/watch?v=CbmEDXq7es0 . "Systems performance provides a different perspective for analysis and tuning, and can help you find performance wins for your databases, applications, and the kernel. However, most of us are not performance or kernel engineers, and have limited time to study this topic. This talk summarizes six important areas of Linux systems performance in 50 minutes: observability tools, methodologies, benchmarking, profiling, tracing, and tuning. Included are recipes for Linux performance analysis and tuning (using vmstat, mpstat, iostat, etc), overviews of complex areas including profiling (perf_events), static tracing (tracepoints), and dynamic tracing (kprobes, uprobes), and much advice about what is and isn't important to learn. This talk is aimed at everyone: DBAs, developers, operations, etc, and in any environment running Linux, bare-metal or the cloud."
This tutor introduces the basic idea of machine learning with a very simple example. Machine learning teaches machines (and me too) to learn to carry out tasks and concepts by themselves. It is that simple, so here is an overview:
http://www.softwareschule.ch/examples/machinelearning.jpg
Best Practices for Benchmarking and Performance Analysis in the Cloud (ENT305...Amazon Web Services
In this session, we explain how to measure the key performance-impacting metrics in a cloud-based application. With specific examples of good and bad tests, we make it clear how to get reliable measurements of CPU, memory, disk, and how to map benchmark results to your application. We also cover the importance of selecting tests wisely, repeating tests, and measuring variability.
Performance is a feature! - London .NET User GroupMatt Warren
Starting with the premise that "Performance is a Feature", this session will look at how to measure, what to measure and how get the best performance from your .NET code.
We will look at real-world examples from the Roslyn code-base and StackOverflow (the product), including how the .NET Garbage Collector needs to be tamed!
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Elevating Tactical DDD Patterns Through Object CalisthenicsDorra BARTAGUIZ
After immersing yourself in the blue book and its red counterpart, attending DDD-focused conferences, and applying tactical patterns, you're left with a crucial question: How do I ensure my design is effective? Tactical patterns within Domain-Driven Design (DDD) serve as guiding principles for creating clear and manageable domain models. However, achieving success with these patterns requires additional guidance. Interestingly, we've observed that a set of constraints initially designed for training purposes remarkably aligns with effective pattern implementation, offering a more ‘mechanical’ approach. Let's explore together how Object Calisthenics can elevate the design of your tactical DDD patterns, offering concrete help for those venturing into DDD for the first time!
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
The Metaverse and AI: how can decision-makers harness the Metaverse for their...Jen Stirrup
The Metaverse is popularized in science fiction, and now it is becoming closer to being a part of our daily lives through the use of social media and shopping companies. How can businesses survive in a world where Artificial Intelligence is becoming the present as well as the future of technology, and how does the Metaverse fit into business strategy when futurist ideas are developing into reality at accelerated rates? How do we do this when our data isn't up to scratch? How can we move towards success with our data so we are set up for the Metaverse when it arrives?
How can you help your company evolve, adapt, and succeed using Artificial Intelligence and the Metaverse to stay ahead of the competition? What are the potential issues, complications, and benefits that these technologies could bring to us and our organizations? In this session, Jen Stirrup will explain how to start thinking about these technologies as an organisation.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
In his public lecture, Christian Timmerer provides insights into the fascinating history of video streaming, starting from its humble beginnings before YouTube to the groundbreaking technologies that now dominate platforms like Netflix and ORF ON. Timmerer also presents provocative contributions of his own that have significantly influenced the industry. He concludes by looking at future challenges and invites the audience to join in a discussion.
Enhancing Performance with Globus and the Science DMZGlobus
ESnet has led the way in helping national facilities—and many other institutions in the research community—configure Science DMZs and troubleshoot network issues to maximize data transfer performance. In this talk we will present a summary of approaches and tips for getting the most out of your network infrastructure using Globus Connect Server.
Essentials of Automations: The Art of Triggers and Actions in FMESafe Software
In this second installment of our Essentials of Automations webinar series, we’ll explore the landscape of triggers and actions, guiding you through the nuances of authoring and adapting workspaces for seamless automations. Gain an understanding of the full spectrum of triggers and actions available in FME, empowering you to enhance your workspaces for efficient automation.
We’ll kick things off by showcasing the most commonly used event-based triggers, introducing you to various automation workflows like manual triggers, schedules, directory watchers, and more. Plus, see how these elements play out in real scenarios.
Whether you’re tweaking your current setup or building from the ground up, this session will arm you with the tools and insights needed to transform your FME usage into a powerhouse of productivity. Join us to discover effective strategies that simplify complex processes, enhancing your productivity and transforming your data management practices with FME. Let’s turn complexity into clarity and make your workspaces work wonders!
Welcome to the first live UiPath Community Day Dubai! Join us for this unique occasion to meet our local and global UiPath Community and leaders. You will get a full view of the MEA region's automation landscape and the AI Powered automation technology capabilities of UiPath. Also, hosted by our local partners Marc Ellis, you will enjoy a half-day packed with industry insights and automation peers networking.
📕 Curious on our agenda? Wait no more!
10:00 Welcome note - UiPath Community in Dubai
Lovely Sinha, UiPath Community Chapter Leader, UiPath MVPx3, Hyper-automation Consultant, First Abu Dhabi Bank
10:20 A UiPath cross-region MEA overview
Ashraf El Zarka, VP and Managing Director MEA, UiPath
10:35: Customer Success Journey
Deepthi Deepak, Head of Intelligent Automation CoE, First Abu Dhabi Bank
11:15 The UiPath approach to GenAI with our three principles: improve accuracy, supercharge productivity, and automate more
Boris Krumrey, Global VP, Automation Innovation, UiPath
12:15 To discover how Marc Ellis leverages tech-driven solutions in recruitment and managed services.
Brendan Lingam, Director of Sales and Business Development, Marc Ellis
UiPath Test Automation using UiPath Test Suite series, part 4DianaGray10
Welcome to UiPath Test Automation using UiPath Test Suite series part 4. In this session, we will cover Test Manager overview along with SAP heatmap.
The UiPath Test Manager overview with SAP heatmap webinar offers a concise yet comprehensive exploration of the role of a Test Manager within SAP environments, coupled with the utilization of heatmaps for effective testing strategies.
Participants will gain insights into the responsibilities, challenges, and best practices associated with test management in SAP projects. Additionally, the webinar delves into the significance of heatmaps as a visual aid for identifying testing priorities, areas of risk, and resource allocation within SAP landscapes. Through this session, attendees can expect to enhance their understanding of test management principles while learning practical approaches to optimize testing processes in SAP environments using heatmap visualization techniques
What will you get from this session?
1. Insights into SAP testing best practices
2. Heatmap utilization for testing
3. Optimization of testing processes
4. Demo
Topics covered:
Execution from the test manager
Orchestrator execution result
Defect reporting
SAP heatmap example with demo
Speaker:
Deepak Rai, Automation Practice Lead, Boundaryless Group and UiPath MVP
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
6. 1. User CPU time
2. System CPU time
3. (1 + 2) i.e. User + System CPU time
4. Realtime
puts Benchmark.measure { 4000.times { |x| x**x } }
# => 0.890000 0.020000 0.910000 (0.909118)
7. Benchmark.bm do |bm|
bm.report { first_algorithm }
bm.report { second_algorithm}
…..
end
#=> user system total real
0.940000 0.010000 0.950000 ( 0.956572)
0.430000 0.010000 0.440000 ( 0.423467)
8. Benchmark.bm(14) do |bm|
bm.report(“first header”) { first_algorithm }
bm.report(“second header”) { second_algorithm}
…..
end
#=> user system total real
first header 0.940000 0.010000 0.950000 (0.956572)
second header 0.430000 0.010000 0.440000 (0.423467)
10. Benchmark.bmbm(20) do |bm|
bm.report('append') do
str1, str2, str3, str4 = 'string1', 'string2', 'string3', 'string4'
1_000_000.times { y = str1 << str2 << str3 << str4 }
end
bm.report('concat') do
str1, str2, str3, str4 = 'string1', 'string2', 'string3', 'string4'
1_000_000.times { y = str1 + str2 + str3 + str4 }
end
bm.report('interpolate') do
str1, str2, str3, str4 = 'string1', 'string2', 'string3', 'string4'
1_000_000.times { y = "#{str1}#{str2}#{str3}#{str4}" }
end
bm.report('interpolate one') do
str1, str2, str3, str4 = 'string1', 'string2', 'string3', 'string4'
1_000_000.times { y = "string1string2string3#{str4}" }
end
end
.bmbm prevents result skewing
11. bmbm does rehearsal which includes any initialisation and GC run
then it does the real benchmark
#=> Rehearsal ---------------------------------------------
append 0.280000 0.000000 0.280000 ( 0.294505)
concat 0.470000 0.020000 0.490000 ( 0.481748)
interpolate 0.430000 0.010000 0.440000 ( 0.433404)
interpolate one 0.320000 0.000000 0.320000 ( 0.323479)
--------------------------------------- total: 1.530000sec
| Tests | user | system | total | real |
|:---------------|:--------:|:--------:|:---------:|-----------:|
|append | 0.260000 | 0.010000 | 0.270000 | (0.265732) |
|concat | 0.400000 | 0.010000 | 0.410000 | (0.396115) |
|interpolate | 0.400000 | 0.000000 | 0.400000 | (0.408096) |
|interpolate one | 0.280000 | 0.010000 | 0.290000 | (0.286443) |
12. Benchmark.bmbm(20) do |bm|
bm.report('gsub') do
1_0_000.times { Date.today.to_s.gsub!('-','') }
end
bm.report('strftime') do
1_0_000.times { Date.today.strftime("%Y%m%d") }
end
end
#=> Rehearsal -------------------------------------------
gsub 0.750000 0.000000 0.750000 ( 0.751547)
strftime 1.320000 0.000000 1.320000 ( 1.320621)
------------------------------------ total: 2.070000sec
| | user | system | total | real |
|:--------|:--------:|:---------:|:--------:|:-----------|
|gsub | 0.710000 | 0.000000 | 0.710000 | (0.709918) |
|strftime | 1.320000 | 0.000000 | 1.320000 | (1.315345) |
13. module Extendable
def name
@name
end
end
class Person
attr_accessor :name
end
require 'ostruct'
Benchmark.bmbm(20) do |bm|
bm.report('Class') do
1_00_000.times { p = Person.new; p.name='Joe'; p.name }
end
bm.report('Extends') do
1_00_000.times { p = Person1.new; p.extend Extendable; p.name='Joe'; p.name }
end
bm.report('Struct') do
1_00_000.times { person2 = Struct.new(:name); p = person2.new('Joe'); p.name }
end
bm.report('OpenStruct') do
1_00_000.times { p = OpenStruct.new(:name => 'Joe'); p.name }
end
end
16. perftools.rb
an adaptation of Google's perftools library to the Ruby land by Aman
Gupta
https://github.com/tmm1/perftools.rb
$gem install perftools.rb
17. does profiling via sampling method, where by default it takes
100 samples a second
19. to see results
Interpreting the above columns:
1. Number of profiling samples in this function
2. Percentage of profiling samples in this function
3. Percentage of profiling samples in the functions printed so far
4. Number of profiling samples in this function and its callees
5. Percentage of profiling samples in this function and its callees
6. Function name
a = ''
PerfTools::CpuProfiler.start("/tmp/profiling/string_concat") do
100_000.times {|x| a += x.to_s}
end
$pprof.rb --text --ignore=Gem /tmp/profiling/string_concat
Total: 2939 samples
1497 50.9% 50.9% 1501 51.1% Object#irb_binding
1438 48.9% 99.9% 1438 48.9% garbage_collector
4 0.1% 100.0% 1500 51.0% Integer#times
20. to see results as graph
bigger the box, the more time spent there
1. Class Name
2. Method Name
3. local (percentage)
4. of cumulative (percentage)
brew install graphviz
$pprof.rb --gif --ignore=Gem /tmp/profiling/string_concat > /tmp/profiling/string_concat.gif
27. To use with Rails
Valid default_printer values are pdf, text, raw, gif, callgrind
# Gemfile
gem 'rack-perftools_profiler', :require => false
# config/environment.rb
config.middleware.use ::Rack::PerftoolsProfiler,
:default_printer => 'gif',
:bundler => true,
:mode => :cputime,
:frequency => 250
28. profile=true will enable profiling
times=10 will hit the page for 10 times
will store the results in profile_ppp_page.txt
RACK_PROFILER=true script/server
curl -o profile_ppp_page.txt
"http://localhost:3000/en/rentals/107605?profile=true×=10"