Does your phone charge as fast as advertised? I measured the latest iPhone, Samsung, OnePlus
Back to Tutorials
techTutorialintermediate

Does your phone charge as fast as advertised? I measured the latest iPhone, Samsung, OnePlus

June 17, 202648 views5 min read

Learn to measure and analyze real phone charging speeds using Python to verify manufacturer claims and compare device performance.

Introduction

In today's fast-paced digital world, phone charging speed has become a critical factor in user experience. Phone manufacturers aggressively market their fast-charging capabilities, but how accurate are these claims? This tutorial will teach you how to measure and analyze real charging speeds using Python and data visualization techniques. You'll learn to parse charging data, calculate actual charging rates, and create meaningful visualizations to compare different devices and chargers.

Prerequisites

  • Basic Python knowledge and familiarity with Jupyter Notebook or Python IDE
  • Python libraries: pandas, matplotlib, numpy
  • Sample charging data files (CSV format) containing time and battery percentage
  • Understanding of basic electrical concepts (voltage, current, power)

Step 1: Setting Up Your Environment

Install Required Libraries

Before we begin analyzing charging data, we need to ensure our Python environment has the necessary libraries. The libraries we'll use include pandas for data manipulation, matplotlib for visualization, and numpy for mathematical calculations.

pip install pandas matplotlib numpy

Why this step? These libraries provide the foundation for data analysis and visualization. Pandas handles our data structures, matplotlib creates visual representations, and numpy performs the mathematical calculations needed for charging rate computations.

Step 2: Preparing Your Charging Data

Create Sample Data Structure

First, we need to create or obtain charging data that includes timestamps and battery percentages. This data represents real charging scenarios from different devices and chargers.

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

# Sample data structure for charging analysis
sample_data = {
    'device': ['iPhone 15 Pro', 'iPhone 15 Pro', 'Samsung Galaxy S24', 'Samsung Galaxy S24', 'OnePlus 12', 'OnePlus 12'],
    'charger': ['OEM', 'Anker', 'OEM', 'Anker', 'OEM', 'Anker'],
    'time_minutes': [0, 10, 20, 30, 40, 50],
    'battery_percentage': [0, 25, 50, 75, 90, 100]
}

df = pd.DataFrame(sample_data)
print(df.head())

Why this step? Creating a structured data format allows us to perform consistent analysis across different devices and charging methods. The time and battery percentage data enables us to calculate actual charging rates rather than relying on manufacturer claims.

Step 3: Data Processing and Charging Rate Calculation

Calculate Charging Rates

Now we'll implement the core functionality to calculate actual charging speeds. This involves computing the rate of battery increase per minute, which directly shows how fast a device charges in real conditions.

def calculate_charging_rates(df):
    # Group by device and charger
    grouped = df.groupby(['device', 'charger'])
    
    rates = []
    for (device, charger), group in grouped:
        # Sort by time to ensure proper calculation
        group = group.sort_values('time_minutes')
        
        # Calculate rate of change (percentage per minute)
        group['rate'] = group['battery_percentage'].diff() / group['time_minutes'].diff()
        
        # Handle first row (NaN rate)
        group.loc[0, 'rate'] = 0
        
        # Calculate average rate for this device and charger
        avg_rate = group['rate'].mean()
        
        rates.append({
            'device': device,
            'charger': charger,
            'average_rate': avg_rate,
            'max_rate': group['rate'].max()
        })
    
    return pd.DataFrame(rates)

# Apply the function to our sample data
charging_rates = calculate_charging_rates(df)
print(charging_rates)

Why this step? Calculating actual charging rates reveals the real performance of devices and chargers, helping separate marketing claims from actual user experience. The rate calculation shows how quickly battery percentage increases over time.

Step 4: Advanced Data Analysis

Identify Charging Phases

Real charging doesn't happen at a constant rate. We'll analyze different charging phases (fast, medium, slow) to understand how charging speeds change over time.

def analyze_charging_phases(df):
    # Create a function to categorize charging phases
    def categorize_phase(row):
        if row['battery_percentage'] < 20:
            return 'Initial Fast Charge'
        elif row['battery_percentage'] < 80:
            return 'Standard Charge'
        else:
            return 'Top-up Charge'
    
    # Apply categorization
    df['phase'] = df.apply(categorize_phase, axis=1)
    
    # Group by phase to see average rates
    phase_rates = df.groupby(['device', 'charger', 'phase'])['rate'].mean().reset_index()
    
    return phase_rates

# Apply phase analysis
phase_analysis = analyze_charging_phases(df)
print(phase_analysis)

Why this step? Charging phases reveal important insights about how devices manage power delivery. Understanding these phases helps identify when devices switch between fast, standard, and slow charging modes, which affects overall user experience.

Step 5: Creating Visualizations

Generate Charging Graphs

Visual representations make it easy to compare charging performance across different devices and chargers. We'll create line graphs showing charging curves for each combination.

def create_charging_charts(df):
    # Create subplots
    fig, axes = plt.subplots(2, 3, figsize=(15, 10))
    fig.suptitle('Charging Performance Comparison', fontsize=16)
    
    devices = df['device'].unique()
    chargers = df['charger'].unique()
    
    for i, device in enumerate(devices):
        for j, charger in enumerate(chargers):
            if i * len(chargers) + j >= len(axes.flat):
                break
            
            # Filter data for this device and charger
            device_data = df[(df['device'] == device) & (df['charger'] == charger)]
            
            # Plot charging curve
            axes[i, j].plot(device_data['time_minutes'], device_data['battery_percentage'], 
                           marker='o', linewidth=2, markersize=6)
            axes[i, j].set_title(f'{device} - {charger}')
            axes[i, j].set_xlabel('Time (minutes)')
            axes[i, j].set_ylabel('Battery Percentage')
            axes[i, j].grid(True, alpha=0.3)
    
    plt.tight_layout()
    plt.show()

# Generate the charts
create_charging_charts(df)

Why this step? Visualizations provide immediate insights that are difficult to grasp from raw numbers alone. Charts make it easy to spot patterns, identify outliers, and compare performance across different devices and charging methods at a glance.

Step 6: Generate Performance Report

Create Summary Analysis

Finally, we'll compile our findings into a comprehensive report that summarizes charging performance for each device and charger combination.

def generate_performance_report(df):
    # Calculate comprehensive metrics
    report = df.groupby(['device', 'charger']).agg({
        'battery_percentage': ['max', 'mean'],
        'time_minutes': ['max'],
        'rate': ['mean', 'max']
    }).round(2)
    
    # Flatten column names
    report.columns = ['max_battery', 'avg_battery', 'max_time', 'avg_rate', 'max_rate']
    
    # Add charging efficiency metric
    report['efficiency_score'] = report['avg_rate'] / report['max_rate']
    
    return report

# Generate and display the report
performance_report = generate_performance_report(df)
print(performance_report)

Why this step? A comprehensive report consolidates all our analysis into actionable insights. It provides a clear comparison framework that helps users make informed decisions about device and charger purchases based on real performance data rather than marketing claims.

Summary

This tutorial demonstrated how to analyze real charging performance data using Python. We learned to calculate actual charging rates, identify different charging phases, create meaningful visualizations, and generate comprehensive performance reports. By implementing these techniques, you can independently verify manufacturer claims and make data-driven decisions about mobile device charging.

The key takeaway is that while manufacturers often advertise peak charging speeds, real-world performance varies significantly based on device design, software optimization, and charger quality. This analytical approach allows you to separate marketing hype from actual user experience.

Source: ZDNet AI

Related Articles