Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

example: One Billion Rows Challenge in V #22955

Open
1 of 2 tasks
enghitalo opened this issue Nov 23, 2024 · 1 comment
Open
1 of 2 tasks

example: One Billion Rows Challenge in V #22955

enghitalo opened this issue Nov 23, 2024 · 1 comment
Labels
Feature Request This issue is made to request a feature.

Comments

@enghitalo
Copy link
Contributor

enghitalo commented Nov 23, 2024

Describe the feature

Inspirations

Use Case

example, CI

Proposed Solution

No response

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

latest

Environment details (OS name and version, etc.)

all

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@enghitalo enghitalo added the Feature Request This issue is made to request a feature. label Nov 23, 2024
@JalonSolov
Copy link
Contributor

Here's one of the files converted... I did it back in March...

create-sample.v

import benchmark
import math
import os
import rand

struct City {
        city string
        mean f64
}

const cities = [
        City{'Abha', 18.0},
        City{'Abidjan', 26.0},
        City{'Abéché', 29.4},
        City{'Accra', 26.4},
        City{'Addis Ababa', 16.0},
        City{'Adelaide', 17.3},
        City{'Aden', 29.1},
        City{'Ahvaz', 25.4},
        City{'Albuquerque', 14.0},
        City{'Alexandra', 11.0},
        City{'Alexandria', 20.0},
        City{'Algiers', 18.2},
        City{'Alice Springs', 21.0},
        City{'Almaty', 10.0},
        City{'Amsterdam', 10.2},
        City{'Anadyr', -6.9},
        City{'Anchorage', 2.8},
        City{'Andorra la Vella', 9.8},
        City{'Ankara', 12.0},
        City{'Antananarivo', 17.9},
        City{'Antsiranana', 25.2},
        City{'Arkhangelsk', 1.3},
        City{'Ashgabat', 17.1},
        City{'Asmara', 15.6},
        City{'Assab', 30.5},
        City{'Astana', 3.5},
        City{'Athens', 19.2},
        City{'Atlanta', 17.0},
        City{'Auckland', 15.2},
        City{'Austin', 20.7},
        City{'Baghdad', 22.77},
        City{'Baguio', 19.5},
        City{'Baku', 15.1},
        City{'Baltimore', 13.1},
        City{'Bamako', 27.8},
        City{'Bangkok', 28.6},
        City{'Bangui', 26.0},
        City{'Banjul', 26.0},
        City{'Barcelona', 18.2},
        City{'Bata', 25.1},
        City{'Batumi', 14.0},
        City{'Beijing', 12.9},
        City{'Beirut', 20.9},
        City{'Belgrade', 12.5},
        City{'Belize City', 26.7},
        City{'Benghazi', 19.9},
        City{'Bergen', 7.7},
        City{'Berlin', 10.3},
        City{'Bilbao', 14.7},
        City{'Birao', 26.5},
        City{'Bishkek', 11.3},
        City{'Bissau', 27.0},
        City{'Blantyre', 22.2},
        City{'Bloemfontein', 15.6},
        City{'Boise', 11.4},
        City{'Bordeaux', 14.2},
        City{'Bosaso', 30.0},
        City{'Boston', 10.9},
        City{'Bouaké', 26.0},
        City{'Bratislava', 10.5},
        City{'Brazzaville', 25.0},
        City{'Bridgetown', 27.0},
        City{'Brisbane', 21.4},
        City{'Brussels', 10.5},
        City{'Bucharest', 10.8},
        City{'Budapest', 11.3},
        City{'Bujumbura', 23.8},
        City{'Bulawayo', 18.9},
        City{'Burnie', 13.1},
        City{'Busan', 15.0},
        City{'Cabo San Lucas', 23.9},
        City{'Cairns', 25.0},
        City{'Cairo', 21.4},
        City{'Calgary', 4.4},
        City{'Canberra', 13.1},
        City{'Cape Town', 16.2},
        City{'Changsha', 17.4},
        City{'Charlotte', 16.1},
        City{'Chiang Mai', 25.8},
        City{'Chicago', 9.8},
        City{'Chihuahua', 18.6},
        City{'Chișinău', 10.2},
        City{'Chittagong', 25.9},
        City{'Chongqing', 18.6},
        City{'Christchurch', 12.2},
        City{'City of San Marino', 11.8},
        City{'Colombo', 27.4},
        City{'Columbus', 11.7},
        City{'Conakry', 26.4},
        City{'Copenhagen', 9.1},
        City{'Cotonou', 27.2},
        City{'Cracow', 9.3},
        City{'Da Lat', 17.9},
        City{'Da Nang', 25.8},
        City{'Dakar', 24.0},
        City{'Dallas', 19.0},
        City{'Damascus', 17.0},
        City{'Dampier', 26.4},
        City{'Dar es Salaam', 25.8},
        City{'Darwin', 27.6},
        City{'Denpasar', 23.7},
        City{'Denver', 10.4},
        City{'Detroit', 10.0},
        City{'Dhaka', 25.9},
        City{'Dikson', -11.1},
        City{'Dili', 26.6},
        City{'Djibouti', 29.9},
        City{'Dodoma', 22.7},
        City{'Dolisie', 24.0},
        City{'Douala', 26.7},
        City{'Dubai', 26.9},
        City{'Dublin', 9.8},
        City{'Dunedin', 11.1},
        City{'Durban', 20.6},
        City{'Dushanbe', 14.7},
        City{'Edinburgh', 9.3},
        City{'Edmonton', 4.2},
        City{'El Paso', 18.1},
        City{'Entebbe', 21.0},
        City{'Erbil', 19.5},
        City{'Erzurum', 5.1},
        City{'Fairbanks', -2.3},
        City{'Fianarantsoa', 17.9},
        City{'Flores,  Petén', 26.4},
        City{'Frankfurt', 10.6},
        City{'Fresno', 17.9},
        City{'Fukuoka', 17.0},
        City{'Gabès', 19.5},
        City{'Gaborone', 21.0},
        City{'Gagnoa', 26.0},
        City{'Gangtok', 15.2},
        City{'Garissa', 29.3},
        City{'Garoua', 28.3},
        City{'George Town', 27.9},
        City{'Ghanzi', 21.4},
        City{'Gjoa Haven', -14.4},
        City{'Guadalajara', 20.9},
        City{'Guangzhou', 22.4},
        City{'Guatemala City', 20.4},
        City{'Halifax', 7.5},
        City{'Hamburg', 9.7},
        City{'Hamilton', 13.8},
        City{'Hanga Roa', 20.5},
        City{'Hanoi', 23.6},
        City{'Harare', 18.4},
        City{'Harbin', 5.0},
        City{'Hargeisa', 21.7},
        City{'Hat Yai', 27.0},
        City{'Havana', 25.2},
        City{'Helsinki', 5.9},
        City{'Heraklion', 18.9},
        City{'Hiroshima', 16.3},
        City{'Ho Chi Minh City', 27.4},
        City{'Hobart', 12.7},
        City{'Hong Kong', 23.3},
        City{'Honiara', 26.5},
        City{'Honolulu', 25.4},
        City{'Houston', 20.8},
        City{'Ifrane', 11.4},
        City{'Indianapolis', 11.8},
        City{'Iqaluit', -9.3},
        City{'Irkutsk', 1.0},
        City{'Istanbul', 13.9},
        City{'İzmir', 17.9},
        City{'Jacksonville', 20.3},
        City{'Jakarta', 26.7},
        City{'Jayapura', 27.0},
        City{'Jerusalem', 18.3},
        City{'Johannesburg', 15.5},
        City{'Jos', 22.8},
        City{'Juba', 27.8},
        City{'Kabul', 12.1},
        City{'Kampala', 20.0},
        City{'Kandi', 27.7},
        City{'Kankan', 26.5},
        City{'Kano', 26.4},
        City{'Kansas City', 12.5},
        City{'Karachi', 26.0},
        City{'Karonga', 24.4},
        City{'Kathmandu', 18.3},
        City{'Khartoum', 29.9},
        City{'Kingston', 27.4},
        City{'Kinshasa', 25.3},
        City{'Kolkata', 26.7},
        City{'Kuala Lumpur', 27.3},
        City{'Kumasi', 26.0},
        City{'Kunming', 15.7},
        City{'Kuopio', 3.4},
        City{'Kuwait City', 25.7},
        City{'Kyiv', 8.4},
        City{'Kyoto', 15.8},
        City{'La Ceiba', 26.2},
        City{'La Paz', 23.7},
        City{'Lagos', 26.8},
        City{'Lahore', 24.3},
        City{'Lake Havasu City', 23.7},
        City{'Lake Tekapo', 8.7},
        City{'Las Palmas de Gran Canaria', 21.2},
        City{'Las Vegas', 20.3},
        City{'Launceston', 13.1},
        City{'Lhasa', 7.6},
        City{'Libreville', 25.9},
        City{'Lisbon', 17.5},
        City{'Livingstone', 21.8},
        City{'Ljubljana', 10.9},
        City{'Lodwar', 29.3},
        City{'Lomé', 26.9},
        City{'London', 11.3},
        City{'Los Angeles', 18.6},
        City{'Louisville', 13.9},
        City{'Luanda', 25.8},
        City{'Lubumbashi', 20.8},
        City{'Lusaka', 19.9},
        City{'Luxembourg City', 9.3},
        City{'Lviv', 7.8},
        City{'Lyon', 12.5},
        City{'Madrid', 15.0},
        City{'Mahajanga', 26.3},
        City{'Makassar', 26.7},
        City{'Makurdi', 26.0},
        City{'Malabo', 26.3},
        City{'Malé', 28.0},
        City{'Managua', 27.3},
        City{'Manama', 26.5},
        City{'Mandalay', 28.0},
        City{'Mango', 28.1},
        City{'Manila', 28.4},
        City{'Maputo', 22.8},
        City{'Marrakesh', 19.6},
        City{'Marseille', 15.8},
        City{'Maun', 22.4},
        City{'Medan', 26.5},
        City{"Mek'ele", 22.7},
        City{'Melbourne', 15.1},
        City{'Memphis', 17.2},
        City{'Mexicali', 23.1},
        City{'Mexico City', 17.5},
        City{'Miami', 24.9},
        City{'Milan', 13.0},
        City{'Milwaukee', 8.9},
        City{'Minneapolis', 7.8},
        City{'Minsk', 6.7},
        City{'Mogadishu', 27.1},
        City{'Mombasa', 26.3},
        City{'Monaco', 16.4},
        City{'Moncton', 6.1},
        City{'Monterrey', 22.3},
        City{'Montreal', 6.8},
        City{'Moscow', 5.8},
        City{'Mumbai', 27.1},
        City{'Murmansk', 0.6},
        City{'Muscat', 28.0},
        City{'Mzuzu', 17.7},
        City{"N'Djamena", 28.3},
        City{'Naha', 23.1},
        City{'Nairobi', 17.8},
        City{'Nakhon Ratchasima', 27.3},
        City{'Napier', 14.6},
        City{'Napoli', 15.9},
        City{'Nashville', 15.4},
        City{'Nassau', 24.6},
        City{'Ndola', 20.3},
        City{'New Delhi', 25.0},
        City{'New Orleans', 20.7},
        City{'New York City', 12.9},
        City{'Ngaoundéré', 22.0},
        City{'Niamey', 29.3},
        City{'Nicosia', 19.7},
        City{'Niigata', 13.9},
        City{'Nouadhibou', 21.3},
        City{'Nouakchott', 25.7},
        City{'Novosibirsk', 1.7},
        City{'Nuuk', -1.4},
        City{'Odesa', 10.7},
        City{'Odienné', 26.0},
        City{'Oklahoma City', 15.9},
        City{'Omaha', 10.6},
        City{'Oranjestad', 28.1},
        City{'Oslo', 5.7},
        City{'Ottawa', 6.6},
        City{'Ouagadougou', 28.3},
        City{'Ouahigouya', 28.6},
        City{'Ouarzazate', 18.9},
        City{'Oulu', 2.7},
        City{'Palembang', 27.3},
        City{'Palermo', 18.5},
        City{'Palm Springs', 24.5},
        City{'Palmerston North', 13.2},
        City{'Panama City', 28.0},
        City{'Parakou', 26.8},
        City{'Paris', 12.3},
        City{'Perth', 18.7},
        City{'Petropavlovsk-Kamchatsky', 1.9},
        City{'Philadelphia', 13.2},
        City{'Phnom Penh', 28.3},
        City{'Phoenix', 23.9},
        City{'Pittsburgh', 10.8},
        City{'Podgorica', 15.3},
        City{'Pointe-Noire', 26.1},
        City{'Pontianak', 27.7},
        City{'Port Moresby', 26.9},
        City{'Port Sudan', 28.4},
        City{'Port Vila', 24.3},
        City{'Port-Gentil', 26.0},
        City{'Portland City{OR}', 12.4},
        City{'Porto', 15.7},
        City{'Prague', 8.4},
        City{'Praia', 24.4},
        City{'Pretoria', 18.2},
        City{'Pyongyang', 10.8},
        City{'Rabat', 17.2},
        City{'Rangpur', 24.4},
        City{'Reggane', 28.3},
        City{'Reykjavík', 4.3},
        City{'Riga', 6.2},
        City{'Riyadh', 26.0},
        City{'Rome', 15.2},
        City{'Roseau', 26.2},
        City{'Rostov-on-Don', 9.9},
        City{'Sacramento', 16.3},
        City{'Saint Petersburg', 5.8},
        City{'Saint-Pierre', 5.7},
        City{'Salt Lake City', 11.6},
        City{'San Antonio', 20.8},
        City{'San Diego', 17.8},
        City{'San Francisco', 14.6},
        City{'San Jose', 16.4},
        City{'San José', 22.6},
        City{'San Juan', 27.2},
        City{'San Salvador', 23.1},
        City{"Sana'a", 20.0},
        City{'Santo Domingo', 25.9},
        City{'Sapporo', 8.9},
        City{'Sarajevo', 10.1},
        City{'Saskatoon', 3.3},
        City{'Seattle', 11.3},
        City{'Ségou', 28.0},
        City{'Seoul', 12.5},
        City{'Seville', 19.2},
        City{'Shanghai', 16.7},
        City{'Singapore', 27.0},
        City{'Skopje', 12.4},
        City{'Sochi', 14.2},
        City{'Sofia', 10.6},
        City{'Sokoto', 28.0},
        City{'Split', 16.1},
        City{"St. John's", 5.0},
        City{'St. Louis', 13.9},
        City{'Stockholm', 6.6},
        City{'Surabaya', 27.1},
        City{'Suva', 25.6},
        City{'Suwałki', 7.2},
        City{'Sydney', 17.7},
        City{'Tabora', 23.0},
        City{'Tabriz', 12.6},
        City{'Taipei', 23.0},
        City{'Tallinn', 6.4},
        City{'Tamale', 27.9},
        City{'Tamanrasset', 21.7},
        City{'Tampa', 22.9},
        City{'Tashkent', 14.8},
        City{'Tauranga', 14.8},
        City{'Tbilisi', 12.9},
        City{'Tegucigalpa', 21.7},
        City{'Tehran', 17.0},
        City{'Tel Aviv', 20.0},
        City{'Thessaloniki', 16.0},
        City{'Thiès', 24.0},
        City{'Tijuana', 17.8},
        City{'Timbuktu', 28.0},
        City{'Tirana', 15.2},
        City{'Toamasina', 23.4},
        City{'Tokyo', 15.4},
        City{'Toliara', 24.1},
        City{'Toluca', 12.4},
        City{'Toronto', 9.4},
        City{'Tripoli', 20.0},
        City{'Tromsø', 2.9},
        City{'Tucson', 20.9},
        City{'Tunis', 18.4},
        City{'Ulaanbaatar', -0.4},
        City{'Upington', 20.4},
        City{'Ürümqi', 7.4},
        City{'Vaduz', 10.1},
        City{'Valencia', 18.3},
        City{'Valletta', 18.8},
        City{'Vancouver', 10.4},
        City{'Veracruz', 25.4},
        City{'Vienna', 10.4},
        City{'Vientiane', 25.9},
        City{'Villahermosa', 27.1},
        City{'Vilnius', 6.0},
        City{'Virginia Beach', 15.8},
        City{'Vladivostok', 4.9},
        City{'Warsaw', 8.5},
        City{'Washington, D.C.', 14.6},
        City{'Wau', 27.8},
        City{'Wellington', 12.9},
        City{'Whitehorse', -0.1},
        City{'Wichita', 13.9},
        City{'Willemstad', 28.0},
        City{'Winnipeg', 3.0},
        City{'Wrocław', 9.6},
        City{"Xi'an", 14.1},
        City{'Yakutsk', -8.8},
        City{'Yangon', 27.5},
        City{'Yaoundé', 23.8},
        City{'Yellowknife', -4.3},
        City{'Yerevan', 12.4},
        City{'Yinchuan', 9.0},
        City{'Zagreb', 10.7},
        City{'Zanzibar City', 26.0},
        City{'Zürich', 9.3},
]

@[unsafe]
fn rand_nd(mean f64, stddev f64) f64 {
        mut static u := 0.0
        mut static v := 0.0
        mut static phase := 0
        mut z := 0.0

        if phase == 0 {
                u = (rand.f64() + 1.0) / (f64(max_i32) + 2.0)
                v = rand.int() / (f64(max_i32) + 1.0)
                z = math.sqrt(-2 * math.log(u)) * math.sin(2 * math.pi * v)
        } else {
                z = math.sqrt(-2 * math.log(u)) * math.cos(2 * math.pi * v)
        }
        phase = 1 - phase

        return z * stddev + mean
}

fn main() {
        mut n := 1_000_000_000

        if os.args.len > 1 {
                n = os.args[1].int()
        }

        mut fh := os.open_file('measurements.txt', 'w')!
        mut b := benchmark.start()

        for i := 0; i < n; i++ {
                c := rand.int31() % cities.len
                fh.write_string('${cities[c].city};${unsafe{rand_nd(cities[c].mean, -10)}:.1}\n')!
        }

        b.measure('creating ${n} measurements')

        fh.close()
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is made to request a feature.
Projects
None yet
Development

No branches or pull requests

2 participants