<commit_before>//
// SwiftShell_Speed_Tests.swift
// SwiftShell Speed Tests
//
// Created by <NAME> on 28/07/14.
// Copyright (c) 2014 NotTooBad Software. All rights reserved.
//

import SwiftShell
import XCTest

class Stream_Iteration_SpeedTests: XCTestCase {

	let numberoflines = 2000

	func testSpeedNSStringSplit () {

		// won't work outside of a method (6.1 beta 1)
		let longtextpath = pathForTestResource("long text", type: "txt")

		self.measureBlock() {
			let f = open(longtextpath)
			let text = f.read()
			let array = (text.split("\n"))
			
			var i = 0
			var result = ""
			for line in array {
				i++
				result += line
			}
			XCTAssertEqual(i, self.numberoflines)
			XCTAssert(result != "")
			f.closeFile()
		}
	}
	
	// takes a very long time
	func testSpeedSwiftSplit () {
		let longtextpath = pathForTestResource("long text", type: "txt")
		self.measureBlock(){
			let f = open(longtextpath)<commit_msg>pathForTestResource still won't work outside of a method (6.1 beta 2).<commit_after>//
// SwiftShell_Speed_Tests.swift
// SwiftShell Speed Tests
//
// Created by <NAME> on 28/07/14.
// Copyright (c) 2014 NotTooBad Software. All rights reserved.
//

import SwiftShell
import XCTest

class Stream_Iteration_SpeedTests: XCTestCase {

	let numberoflines = 2000

	func testSpeedNSStringSplit () {

		// won't work outside of a method (6.1 beta 2)
		let longtextpath = pathForTestResource("long text", type: "txt")

		self.measureBlock() {
			let f = open(longtextpath)
			let text = f.read()
			let array = (text.split("\n"))
			
			var i = 0
			var result = ""
			for line in array {
				i++
				result += line
			}
			XCTAssertEqual(i, self.numberoflines)
			XCTAssert(result != "")
			f.closeFile()
		}
	}
	
	// takes a very long time
	func testSpeedSwiftSplit () {
		let longtextpath = pathForTestResource("long text", type: "txt")
		self.measureBlock(){
			let f = open(longtextpath)
{'fraction_non_alphanumeric': 0.12205343111576741, 'fraction_numerical': 0.020429544264012573, 'mean_word_length': 3.2163355408388523, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6643689', 'n_tokens_mistral': 755, 'n_tokens_neox': 623, 'n_words': 185}