Skip to content

Instantly share code, notes, and snippets.

View antonkalik's full-sized avatar
💻
coding...

Anton Kalik antonkalik

💻
coding...
View GitHub Profile
@antonkalik
antonkalik / main.go
Created May 19, 2025 07:24
fiber go
package main
import (
"github.com/gofiber/fiber/v2"
)
func main() {
app := fiber.New()
app.Get("/ping", func(c *fiber.Ctx) error {
@antonkalik
antonkalik / main.go
Created May 19, 2025 07:24
Fiber golang
package main
import (
"github.com/gofiber/fiber/v2"
)
func main() {
app := fiber.New()
app.Get("/ping", func(c *fiber.Ctx) error {
@antonkalik
antonkalik / main
Created May 19, 2025 07:23
Fiber for go lang
package main
import (
"github.com/gofiber/fiber/v2"
)
func main() {
app := fiber.New()
app.Get("/ping", func(c *fiber.Ctx) error {
@antonkalik
antonkalik / index.js
Last active May 19, 2025 07:20
express node js
const express = require("express");
const app = express();
app.get("/ping", (req, res) => res.send("pong"));
app.listen(3000, () => console.log("Node.js listening on 3000"));
@antonkalik
antonkalik / main.go
Created May 19, 2025 07:09
goroutine
package main
import (
"fmt"
"sync"
"time"
)
func fakeWork(wg *sync.WaitGroup, id int) {
defer wg.Done()
@antonkalik
antonkalik / index.js
Created May 19, 2025 07:09
node js concurrency
const wait = ms => new Promise(resolve => setTimeout(resolve, ms));
async function fakeWork() {
await wait(100);
}
(async () => {
console.time("Node Concurrency");
await Promise.all(Array.from({ length: 10 }, fakeWork));
console.timeEnd("Node Concurrency");
package main
import (
"fmt"
"time"
)
func main() {
start := time.Now()
@antonkalik
antonkalik / index.js
Last active May 19, 2025 06:52
Fixed version
console.time("Node Loop Benchmark");
import Long from "long";
let sum = Long.ZERO;
for (let i = 0; i < 1_000_000_000; i++) {
sum = sum.add(Long.fromInt(i)); // more efficient for small values
}
console.log("Sum:", sum.toString());
console.timeEnd("Node Loop Benchmark");
console.time("Node Loop Benchmark");
let sum = 0n;
for (let i = 0n; i < 1_000_000_000n; i++) {
sum += i;
}
console.timeEnd("Node Loop Benchmark");
console.log("Sum:", sum.toString());
@antonkalik
antonkalik / index.js
Created May 19, 2025 06:29
Loop Test
console.time("Node Loop Benchmark");
let sum = 0;
for (let i = 0; i < 1_000_000_000; i++) {
sum += i;
}
console.timeEnd("Node Loop Benchmark");
console.log("Sum:", sum);