Skip to content

Commit 6f97b86

Browse files
authored
Merge pull request #2497 from pareenaverma/content_review
Typescript Axion LP tech review
2 parents bdd3bb8 + 634c654 commit 6f97b86

File tree

5 files changed

+74
-61
lines changed

5 files changed

+74
-61
lines changed

content/learning-paths/servers-and-cloud-computing/typescript-on-gcp/_index.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@ cascade:
77

88
minutes_to_complete: 30
99

10-
who_is_this_for: This learning path is intended for software developers deploying and optimizing TypeScript workloads on Linux/Arm64 environments, specifically using Google Cloud C4A virtual machines powered by Axion processors.
10+
who_is_this_for: This is an introductory topic for software developers deploying and optimizing TypeScript workloads on Arm64 Linux environments, specifically using Google Cloud C4A virtual machines powered by Axion processors.
1111

1212
learning_objectives:
1313
- Provision an Arm-based SUSE SLES virtual machine on Google Cloud (C4A with Axion processors)
1414
- Install TypeScript on a SUSE Arm64 (C4A) instance
1515
- Validate TypeScript functionality by creating, compiling, and running a simple TypeScript script on the Arm64 VM
16-
- Benchmark TypeScript performance using a JMH-style custom benchmark with perf_hooks on Arm64 (Aarch64) architecture
16+
- Benchmark TypeScript performance using a JMH-style custom benchmark with perf_hooks on Arm64 architecture
1717

1818
prerequisites:
1919
- A [Google Cloud Platform (GCP)](https://cloud.google.com/free) account with billing enabled
@@ -34,7 +34,6 @@ tools_software_languages:
3434
- TypeScript
3535
- node.js
3636
- npm
37-
- perf_hooks
3837

3938
operatingsystems:
4039
- Linux

content/learning-paths/servers-and-cloud-computing/typescript-on-gcp/background.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ To learn more about Google Axion, refer to the [Introducing Google Axion Process
1818

1919
TypeScript is an open-source, strongly typed programming language developed and maintained by Microsoft.
2020

21-
It is a superset of JavaScript, which means all valid JavaScript code is also valid TypeScript, but TypeScript adds **static typing, interfaces, and advanced tooling** to help developers write more reliable and maintainable code.
21+
It is a superset of JavaScript, which means all valid JavaScript code is also valid TypeScript, but TypeScript adds static typing, interfaces, and advanced tooling to help developers write more reliable and maintainable code.
2222

23-
TypeScript is widely used for **web applications, server-side development (Node.js), and large-scale JavaScript projects** where type safety and code quality are important. Learn more from the [TypeScript official website](https://www.typescriptlang.org/) and its [handbook and documentation](https://www.typescriptlang.org/docs/).
23+
TypeScript is widely used for web applications, server-side development (Node.js), and large-scale JavaScript projects** where type safety and code quality are important. Learn more from the [TypeScript official website](https://www.typescriptlang.org/) and its [handbook and documentation](https://www.typescriptlang.org/docs/).

content/learning-paths/servers-and-cloud-computing/typescript-on-gcp/baseline.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,33 @@ layout: learningpathall
77
---
88

99
## Baseline Setup for TypeScript
10-
This guide covers the **baseline setup and testing** of TypeScript on a **Google Axion C4A virtual machine** running SUSE Linux. The objective is to ensure that the TypeScript environment is installed correctly, that basic compilation works, and that a simple TypeScript script can run on the VM.
10+
This section walks you through the baseline setup and validation of TypeScript on a Google Cloud C4A (Axion Arm64) virtual machine running SUSE Linux.
11+
The goal is to confirm that your TypeScript environment is functioning correctly, from initializing a project to compiling and executing a simple TypeScript file, ensuring a solid foundation before performance or benchmarking steps.
1112

1213
### Set Up a TypeScript Project
13-
Before testing, we need a project folder with all necessary TypeScript dependencies.
14+
Before running any tests, you’ll create a dedicated project directory and initialize a minimal TypeScript environment.
1415

15-
**1. Create project folder**
16+
1. Create project folder
1617

17-
Create a dedicated folder for your TypeScript project:
18+
Start by creating a new folder to hold your TypeScript project files:
1819

1920
```console
2021
mkdir ~/typescript-benchmark
2122
cd ~/typescript-benchmark
2223
```
23-
This ensures all files are organized in one place, separate from system files.
24+
This creates a workspace named `typescript-benchmark` in your home directory, ensuring all TypeScript configuration and source files are organized separately from system files and global modules.
2425

25-
**2. Initialize npm project**
26+
2. Initialize npm project
2627

27-
Initialize a Node.js project with default settings:
28+
Next, initialize a new Node.js project. This creates a `package.json` file that defines your project metadata, dependencies, and scripts.
2829

2930
```console
3031
npm init -y
3132
```
32-
The above command creates a `package.json` file, which manages your project dependencies and scripts.
3333

34-
**3. Install Node.js type definitions**
34+
3. Install Node.js type definitions
3535

36-
These definitions allow TypeScript to understand Node.js APIs, enabling type checking and code autocompletion.
36+
To enable TypeScript to properly recognize Node.js built-in APIs (like fs, path, and process), install the Node.js type definitions package:
3737

3838
```console
3939
npm install --save-dev @types/node
@@ -56,9 +56,9 @@ You should see output similar to:
5656
```
5757

5858
### Baseline Testing
59-
After setting up the project, we perform baseline testing to verify that TypeScript is working correctly on the GCP SUSE VM.
59+
With the TypeScript environment configured, you’ll now perform a baseline functionality test to confirm that TypeScript compilation and execution work correctly on your Google Cloud SUSE Arm64 VM.
6060

61-
**1. Create a Simple TypeScript File**
61+
1. Create a Simple TypeScript File
6262

6363
Create a file named `hello.ts` with the following content:
6464

@@ -71,17 +71,18 @@ console.log(greet("GCP SUSE ARM64"));
7171
```
7272
This simple function demonstrates TypeScript syntax, type annotations, and basic console output.
7373

74-
**2. Compile TypeScript**
74+
2. Compile TypeScript
7575

76-
The TypeScript compiler (`tsc`) converts `hello.ts` into `hello.js`, which can be executed by Node.js.
76+
Use the TypeScript compiler (tsc) to transpile the .ts file into JavaScript:
7777

7878
```console
7979
tsc hello.ts
8080
```
81+
This generates a new file named `hello.js` in the same directory.
8182

82-
**3. Run compiled JavaScript**
83+
3. Run compiled JavaScript
8384

84-
After compiling the TypeScript file into JavaScript (`hello.js`), you need to execute it using `Node.js`. This step verifies that:
85+
Now, execute the compiled JavaScript using Node.js. This step verifies that:
8586

8687
- The TypeScript code was successfully compiled into valid JavaScript.
8788
- The JavaScript code runs correctly in the Node.js runtime on your GCP SUSE VM.
@@ -93,7 +94,9 @@ node hello.js
9394
```
9495

9596
You should see output similar to:
97+
9698
```output
9799
Hello, GCP SUSE ARM64
98100
```
99-
This verifies the basic functionality of the TypeScript installation before proceeding to the benchmarking.
101+
You have successfully verified that your TypeScript environment is working correctly.
102+
Next, you can proceed to TypeScript performance benchmarking to measure compilation and runtime performance on your Google Cloud Arm64 VM.

content/learning-paths/servers-and-cloud-computing/typescript-on-gcp/benchmarking.md

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ layout: learningpathall
99

1010
## JMH-style Custom Benchmarking
1111

12-
This section demonstrates how to **benchmark TypeScript functions** using a JMH-style approach with Node.js `perf_hooks`. Unlike simple `console.time` timing, this method performs **repeated iterations**, calculates the **average execution time**, and provides more **reliable and stable performance measurements** on your Arm64 SUSE VM.
12+
This section demonstrates how to benchmark TypeScript functions using a JMH-style (Java Microbenchmark Harness) methodology implemented with Node.js’s built-in `perf_hooks` module.
13+
Unlike basic `console.time()` measurements, this approach executes multiple iterations, computes the average runtime, and produces stable and repeatable performance data, useful for evaluating workloads on your Google Cloud C4A (Axion Arm64) VM running SUSE Linux.
1314

1415
### Create the Benchmark Script
15-
Create a file named `benchmark_jmh.ts` in your project folder:
16+
Create a file named `benchmark_jmh.ts` inside your project directory with the content below:
1617

1718
```typescript
1819
import { performance } from 'perf_hooks';
@@ -43,30 +44,34 @@ for (let i = 0; i < iterations; i++) {
4344
const averageTime = totalTime / iterations;
4445
console.log(`\nAverage execution time over ${iterations} iterations: ${averageTime.toFixed(3)} ms`);
4546
```
47+
Code explanation:
4648

47-
- **`performance.now()`** → Provides a high-resolution timestamp in milliseconds for precise timing measurements.
48-
- **`sumArray`** → A sample CPU-bound function that sums numbers from 0 to `n`.
49-
- **`iterations`** → Defines how many times the benchmark should run to stabilize results and minimize random variations.
50-
- **`for` loop** → Executes the target function multiple times and records the duration of each run.
51-
- **`totalTime / iterations`** → Calculates the **average execution time** across all runs, similar to how **JMH (Java Microbenchmark Harness)** operates in Java.
49+
| Component | Description |
50+
| ----------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
51+
| **`performance.now()`** | Provides high-resolution timestamps (sub-millisecond precision) for accurate timing. |
52+
| **`sumArray(n)`** | A simple CPU-bound function that sums integers from 0 to `n`. This simulates a computational workload suitable for benchmarking raw arithmetic throughput. |
53+
| **`iterations`** | Defines how many times the test runs. Multiple repetitions reduce noise and help average out one-off delays or GC pauses. |
54+
| **Loop and averaging** | Each run’s duration is recorded; the mean execution time is then reported, mirroring how JMH computes stable results in Java microbenchmarks. |
5255

53-
This JMH-style benchmarking approach provides **more accurate and repeatable performance metrics** than a single execution, making it ideal for performance testing on Arm-based systems.
56+
57+
This JMH-style benchmarking approach provides more accurate and repeatable performance metrics than a single execution, making it ideal for performance testing on Arm-based systems.
5458

5559
### Compile the TypeScript Benchmark
56-
Compile the TypeScript benchmark file into JavaScript:
60+
First, compile the benchmark file from TypeScript to JavaScript using the TypeScript compiler (tsc):
5761

5862
```console
5963
tsc benchmark_jmh.ts
6064
```
61-
This generates a `benchmark_jmh.js` file that can be executed by Node.js.
65+
This command transpiles your TypeScript code into standard JavaScript, generating a file named `benchmark_jmh.js` in the same directory.
66+
The resulting JavaScript can be executed by Node.js, allowing you to measure performance on your Google Cloud C4A (Arm64) virtual machine.
6267

6368
### Run the Benchmark
64-
Execute the compiled JavaScript file:
69+
Now, execute the compiled JavaScript file with Node.js:
6570

6671
```console
6772
node benchmark_jmh.js
6873
```
69-
You should see an output similar to:
74+
You should see output similar to:
7075

7176
```output
7277
Iteration 1: 2.286 ms
@@ -85,21 +90,16 @@ Average execution time over 10 iterations: 0.888 ms
8590

8691
### Benchmark Metrics Explained
8792

88-
- **Iteration times** → Each iteration shows the **time taken for a single execution** of the function being benchmarked.
89-
- **Average execution time** → Calculated as the sum of all iteration times divided by the number of iterations. This provides a **stable measure of typical performance**.
90-
- **Why multiple iterations?**
91-
- Single-run timing can be inconsistent due to factors such as CPU scheduling, memory allocation, or caching.
92-
- Repeating the benchmark multiple times and averaging reduces variability and gives **more reliable performance results**, similar to Java’s JMH benchmarking approach.
93-
**Interpretation:**
94-
- The average execution time reflects how efficient the function is under normal conditions.
95-
- Initial iterations may take longer due to **initialization overhead**, which is common in Node.js performance tests.
93+
* Iteration times → Each iteration represents the time taken for one complete execution of the benchmarked function.
94+
* Average execution time → Calculated as the total of all iteration times divided by the number of iterations. This gives a stable measure of real-world performance.
95+
* Why multiple iterations?
96+
A single run can be affected by transient factors such as CPU scheduling, garbage collection, or memory caching.
97+
Running multiple iterations and averaging the results smooths out variability, producing more repeatable and statistically meaningful data, similar to Java’s JMH benchmarking methodology.
98+
99+
### Interpretation
96100

97-
### Benchmark summary on x86_64
98-
To compare the benchmark results, the following results were collected by running the same benchmark on a `x86 - c4-standard-4` (4 vCPUs, 15 GB Memory) x86_64 VM in GCP, running SUSE:
99-
100-
| Iteration | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Average |
101-
|-----------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|---------|
102-
| Time (ms) | 3.217 | 0.631 | 0.632 | 0.611 | 0.612 | 0.614 | 0.614 | 0.611 | 0.606 | 0.532 | 0.868 |
101+
The average execution time reflects how efficiently the function executes under steady-state conditions.
102+
The first iteration often shows higher latency because Node.js performing initial JIT (Just-In-Time) compilation and optimization, a common warm-up behavior in JavaScript/TypeScript benchmarks.
103103

104104
### Benchmark summary on Arm64
105105
Results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm64 VM in GCP (SUSE):
@@ -108,11 +108,12 @@ Results from the earlier run on the `c4a-standard-4` (4 vCPU, 16 GB memory) Arm6
108108
|-----------|-------|-------|-------|-------|-------|-------|-------|-------|-------|-------|---------|
109109
| Time (ms) | 2.286 | 0.749 | 1.145 | 0.674 | 0.671 | 0.671 | 0.672 | 0.667 | 0.667 | 0.673 | 0.888 |
110110

111-
### TypeScript performance benchmarking comparison on Arm64 and x86_64
111+
### TypeScript performance benchmarking summary on Arm64
112112

113-
When you compare the benchmarking results, you will notice that on the Google Axion C4A Arm-based instances:
113+
When you look at the benchmarking results, you will notice that on the Google Axion C4A Arm-based instances:
114114

115115
- The average execution time on Arm64 (~0.888 ms) shows that CPU-bound TypeScript operations run efficiently on Arm-based VMs.
116116
- Initial iterations may show slightly higher times due to runtime warm-up and optimization overhead, which is common across architectures.
117117
- Arm64 demonstrates stable iteration times after the first run, indicating consistent performance for repeated workloads.
118-
- Compared to typical x86_64 VMs, Arm64 performance is comparable for lightweight TypeScript computations, with potential advantages in power efficiency and cost for cloud deployments.
118+
119+
This demonstrates that Google Cloud C4A Arm64 virtual machines provide production-grade stability and throughput for TypeScript workloads, whether used for application logic, scripting, or performance-critical services.

content/learning-paths/servers-and-cloud-computing/typescript-on-gcp/installation.md

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,44 @@ layout: learningpathall
77
---
88

99
## Install TypeScript on GCP VM
10-
This page guides you through installing **TypeScript** and its prerequisites on a **GCP SUSE Arm64 VM**. We will install Node.js, npm, TypeScript, and ts-node, and verify that everything works correctly.
10+
This section walks you through installing TypeScript and its dependencies on a Google Cloud Platform (GCP) SUSE Arm64 virtual machine. You’ll install Node.js, npm, TypeScript, and ts-node, and verify that everything works correctly.
11+
12+
Running TypeScript on Google Cloud C4A instances, powered by Axion Arm64 processors, provides a high-performance and energy-efficient platform for Node.js-based workloads.
1113

1214
### Update SUSE System
13-
Before installing new packages, refresh the repositories and update existing packages:
15+
Before installing new packages, refresh the repositories and update existing ones to ensure your environment is current and secure:
1416

1517
```console
1618
sudo zypper refresh
1719
sudo zypper update -y
1820
```
19-
This ensures that your VM has the latest package information and security updates.
21+
Keeping your system up to date ensures that dependencies, libraries, and compilers required for Node.js and TypeScript work seamlessly on the Arm64 architecture.
2022

2123
### Install Node.js and npm
22-
Node.js is required to run TypeScript scripts, and npm is the Node.js package manager:
24+
Node.js provides the JavaScript runtime that powers TypeScript execution, while npm (Node Package Manager) manages project dependencies and global tools.
25+
26+
Install both packages using SUSE’s repositories:
2327

2428
```console
2529
sudo zypper install -y nodejs npm
2630
```
27-
The above command installs Node.js runtime and npm on your GCP SUSE VM.
31+
This command installs the Node.js runtime and npm package manager on your Google Cloud SUSE Arm64 VM.
2832

2933
### Install TypeScript globally
30-
TypeScript (`tsc`) compiles `.ts` files to JavaScript, and ts-node allows you to run TypeScript directly without compiling:
34+
TypeScript (tsc) is the compiler that converts .ts files into JavaScript.
35+
`ts-node` lets you run TypeScript files directly without pre-compiling them. It is useful for testing, scripting, and lightweight development workflows.
36+
37+
Install both globally using npm:
3138

3239
```console
3340
sudo npm install -g typescript ts-node
3441
```
35-
- Installing globally (`-g`) makes `tsc` and `ts-node` available in any directory on your VM.
42+
The `-g` flag installs packages globally, making tsc and ts-node available system-wide.
43+
44+
This approach simplifies workflows for developers running multiple TypeScript projects on the same VM.
3645

3746
### Verify installations
38-
Check that Node.js, npm, TypeScript, and ts-node are installed correctly:
47+
Check that Node.js, npm, TypeScript, and ts-node are all installed correctly:
3948

4049
```console
4150
node -v
@@ -44,7 +53,7 @@ tsc -v
4453
ts-node -v
4554
```
4655

47-
**Output:**
56+
The expected output is:
4857

4958
```output
5059
>node -v
@@ -57,4 +66,5 @@ Version 5.9.3
5766
v10.9.2
5867
```
5968

60-
These version outputs confirm that the Node.js and TypeScript are installed correctly and are ready for development or benchmarking.
69+
Node.js, npm, and TypeScript are now successfully installed and verified on your Google Cloud C4A (Arm64) virtual machine.
70+
You’re ready to create and execute TypeScript scripts for testing, deployment, or performance benchmarking.

0 commit comments

Comments
 (0)